tr_quest tr_quest - 12 days ago 5
Java Question

Design Pattern for Module that continuously checks if other modules in the system are working?

I am implementing a java project where there are multiple decoupled modules interacting with a shared service (database/web service).

There is a health checker module that continuously polls all the modules to see if they are functioning or not. If a module is found to be inactive or not functioning properly, the health checker module performs a repair and restarts it.

Which behavioral pattern would this belong to?

Answer

The Health Checker should basically keep track of all how the other modules work.

So the health checker can be an observe for changes and hence you can go with Observer Design Pattern. The modules should contain a method which should notify the Health Checker everytime there is a change.

To keep the shared resource in control you can use Resource Management Design Pattern or Singleton Design Pattern.

You can also read this MSDN Blog which discusses a similar kind of application you are talking about.

Another similar design pattern can be this.