The following scenario occurred on our system this weekend:
-
Our bounded context received two events at the same time from our subscriber service, the events are named VerificationRequestedEvent & ValidationRequestedEvent.
-
Each event is handled by the re-hydrated aggregate which has an current event count of 32.
-
The VerificationRequestedEvent completes first and adds a new event to the aggregate, VerificationSuccessfulEvent (event 33).
-
The ValidationRequestedEvent event subsequently completes and attempts to also add new event to the aggregate named ValidationSuccessfullEvent. However as the aggregate was at event count 32 when the ValidationRequestedEvent event was
handled it attempts to write event 33 which has already been written. This give us the following error:
EventStore.ClientAPI.Exceptions.WrongExpectedVersionException: Append failed due to WrongExpectedVersion. Stream: Sender-d2b798d15bb24479b89c2e69f6f5d8df, Expected version: 33
What is the best solution/way forward with this issue?