Hi all,
The problem description is as follows:
I need to fetch a couple of files across the network, each file residing on different machines on the network. In some cases, I use FTP to retrieve them and for rest I directly get data from the database.
Since, on a distributed environment, things can go wrong, therefore, I have a dedicated object maintaining a job queuue responsible for fetching different files across the netowrk. If an attempt fails for whatsoever reason, the dedicated object will try again after a time interval. It continues its attempt at regular intervals until it succeeds or instructed by a master controller object to terminate all its attempts.
When the dedicated object successfully fetches a particular file, it must inform/notify the master controller object about it so that it can do further processing.
Now, its for the above situation I intend to use the observer
pattern. Here, the subject is the dedicated object and the observer is the master controller object.
The motivation behind this is:- The master controller assigns a set of jobs to the dedicated object to be executed. But, the master controller does not know at what point of time and in what order they will get executed. The dedicated object must notify whenever it executed a task in its job queue to the controller so that it can take further action.
Also, by using the observer pattern, I am achieving the loose coupling between the controller and dedicated object. Therefore, the dedicated object need not have any reference of the controller.
Also, I intend to run the dedicated object as a seperate
thread.
Its for above reasons I intend to use Observer pattern. Can you please let me know your comments on this - anyone for or against it ?
Thanks in advance,
------------------
- Sathvathsan Sampath