I'm building a DDD/CQRS Event Sourcing application. (.NET, EventStore)
I read a lot of articles about it, especially the famous bank account topic.
As reminder, we have the following events sequence:
- BankAccountCreated
- Deposited
- WithDrawn
- ChangedOwner
- Deposited
But I've never found a blog post explaining how to validate the events sequence? I mean, what happen if I receive the Deposited event first, before BankAccountCreated? In other words, how do I check whether the bank account is created? How do I know the stream is in a valid state?
Do I have to call the read-model? every time? in each event? each method of the aggregate? What happen if the user sent it twice and the readmodel is not sync, yet?
I've read a lot of stuff about Event Sourcing, maybe not enough ^^, but I didn't find any information regarding the consistency about the events flow.
In my application, I cannot apply an event if the "first" event (ContactAdded) does not exist. Does it mean I have to call the EventStore each time I need to do something?
Thanks for your help.