Hi - given a following setup:
- EventStore (what a surprise!) with a persistent subscription on a certain stream
- MongoDb for read models
- Kubernetes hosting three pods with a listener on the persistent subscription
- Three events available within the persistent subscription: event 1 updates a property A, event 2 updates a property B and event 3 again updates a property A
I assume that it might result in Pod 1 receiving event 1, Pod 2 receiving event 2 and Pod 3 receiving event 3. How can I ensure, that my read model is updated in the correct order? Of course I could skip event 1 as event 3 updates the same property again. But I cannot rely on some version number alone, as event 2 must not get lost.
So I am thinking on defering executing of event 2 and event 3 in their pods until the current version of my read model is “[event version] - 1”. Can I rely on the presence of such an version number that always increments by 1?
Is there any other way I could ensure that my read model represents the correct state?