I'm learning cqrs right now.
Problem
My concern is event ordering.
Assumption 1:
user service is creating user and three events in order.
Each event was sent after each step was finished in write model.
- Event A: user ABC created
- Event B: changed email for user ABC to abc@mail
- Event C: change email for user ABC to abc2@mail
Assumption 2
: I have 3 instances of same microservice read app that will handle this events.
Without ordering email can be changed before account was created or even worse eventB can override eventC email value.
I found two things: vector clock
and consuming history not event
.
vector clock
--> forces me to create complicated logic to handle that
and will decrease performance
consuming history not event
--> not solve the problem. Consumer 1 can take
100 events ...-B but consumer 2 will take events C-... and still will try to
override email in non existing account.
Question:
What are best practices to handle this case?