Lets say we have a micro service U which manages user data. Now we have two other micro services A and B that require user data which is replicated through e.g. a messaging queue. Both micro services A and B update some data based on the new user data and publish the result to another queue.
Now we have another service C wich depends on the the results from service A and B. Service C will aggregate the data from A and B and publish the result. Now we have two issues:
- Each update of a users data in Service U will result in two updates in Service C (because it will first trigger an update in Service A and B and each of those updates will trigger one update in C). If there are more services in the chain after C that also require date from U or data based on U this may get even worse.
- The data from A and B may be based on different versions of the user data from U. If Service C aggregates both it may result in inconsistent data.
Are they any solution patterns for this problem?
The one I currently have in mind is: services A and B must include in their result which version of U there data is based on. Then C can wait until it has a consistent version of data from A and B that is based on the same version of U. The disadvantage I see with this solution is that now C has to know that data form A and B is based on U.