Search code examples
databasedesign-patternsnotificationsobserver-patternapi-design

what pattern or process to notify multiple systems about changes in another system


Imagine a system X with an http api with a lot of data from a (mysql) database. Imagine multiple systems being dependent on this data but doing very different tasks. Some work on one data-set others work on a huge bunch of data-sets. The data changes to an unknown number of sets in system X do not have a periodic rhythm. There can be a large number of changes in a very short time.

The other systems must somehow be aware of those data changes and react accordingly. What pattern or process is advisable to keep bottlenecks in all system at the lowest level. So that you prevent that either system X won't be able to handle to notify all other systems or handle all other systems trying to fetch changes. And prevent other systems to slow down because they need to fetch large datasets or wait for system X being overloaded.

Also ideally all systems should not need to know about the other systems. Especially system X shouldn't need to implement specific notification methods for each system.

Would the observer pattern be applicable in this situation?


Solution

  • Going by your requirement that no systems should not need to know about the other systems, I think you should go for pub-sub pattern. To understand how it is different from Observer pattern, please refer my other response: Is Observer pattern and pub-sub same when a database is used in the implementation?

    Observer pattern would have work if you didn't had this requirement of systems being unaware of each other. Although if it's ok to know the Subject system but all other systems (i.e. Observer systems) being unaware of each other, in that case even Observer pattern should be good enough as well