Race between & Ordering of the events
j30ng opened this issue · 2 comments
Hi André. Thanks for sharing this wonderful example.
I wanted to ask your opinion on one thing.
This stores the event first in the event store (which I assume is the single source of truth), and publish the event through the event bus. But if you try to scale and there are multiple instances of the application (assume now we have an external event store and and external event bus, say mongodb and kafka perhaps) each trying to store and then publish events, would that not mess up the ordering of the events?
For example say there is a race between AccountDepositedEvent
D and AccountWithdrawnEvent
W. What could happen is that in the event store you have D stored before W, but have D published after W through the event bus. Then application states restored through replaying event processing would not be the same as the original.
What would be your approach to solve this problem?
Never mind, I overlooked the OptimisticLockingException part ;)
It shouldn't cause a problem if I can enforce the same optimistic locking mechanism when storing events in the event store.
Hey, glad to hear you found a way forward with the examples 🙂
Cheers