Thinking within a Service Oriented Architecture / Microservices / Enterprise Integration framework how does one avoid infinite loops when publishing messages between systems, especially when one has limited control over certain services (e.g third party SaaS products).
- System A tracks Entity E – I have very little control over how System A behaves, it is propertiary.
- System B also wants to track Entity E.
A --> B: E is created, A publishes a message to B that E has been created.
B --> A: B issues a new global identifier for E and sends this back to A.
A --> B: A sends a new message about this latest update to B (it is not aware that the update has come from B).
The problem is that A will now recieve a new update and publish a new message to B, which may in turn send a message back, starting an infinite loop / cycle.
Because I have little control over the internal behaviour of A I must handle this problem within system B.
How can we avoid these kind of problems?
I have considered
- etag style hash key against entity E which system B can compare to what it knows of E to avoid publishing further messages on changes
- comparing udpate timestamps, this will not work because messages from B can cause updates