In CQRS (event-sourced), do you need a global sequence counter in the event store?
Posted
by Jon M
on Stack Overflow
See other posts from Stack Overflow
or by Jon M
Published on 2010-06-01T09:21:35Z
Indexed on
2010/06/01
9:23 UTC
Read the original article
Hit count: 221
In trying to get my head around CQRS (and DDD in general) I have come across situations when two events occur on different aggregates but the order of them has domain meaning. If so then they could happen so close together that a timestamp (as used by the sample implementations I have seen) cannot differentiate them, meaning the event store doesn't contain a 'complete' representation of the domain as there is ambiguity over the order in which events occurred.
As an example, the domain could fire a CustomerCreatedEvent
which applies to the Customer
aggregate, and then a CustomerAssignedToAgent
event on the Agent
aggregate. The CustomerAssignedToAgent
event doesn't make sense if it occurs before the CustomerCreatedEvent
, but typically both of these might be fired as a result of one operation which makes it likely that the timestamps would effectively be the same.
So am I just modelling things badly? Should there ever be a situation where the sequence of events across different aggregates is important? Or should you keep a global sequence number on your event store, so that you can identify the exact sequence in which events occurred?
© Stack Overflow or respective owner