In my application, I have a scenario where if a change occurs on a particular module, it has to be notified to few other modules. I thought an observer pattern would fit here, by keeping the module on which the change will occur as subject and the modules to be notified as observers.
But going by the principle of observer pattern, the observers are independent of each other. There should be no connection between the observers. In my case, though the modules are different, they are dependent. The successful completion of execution of the first module is important for the next module to execute. Also if the module x fails, all changes made by module 1 to module x-1 has to be reverted. That is, either all the modules has to successfully execute or we have to rollback to previous state. You can imagine it like a transaction. Then I realized I was wrong that observer pattern is not the right way to implement this.
I am kind of stuck up here to come up with a clean design, where there are set of modules who needs to handled when a change in subject happens, but with the constraint the modules are dependent on each other. Can someone help me with this problem to come up with a good design?