I understand that by default SequentialPerAggregatePolicy is used.
“Event handlers may have specific expectations on the ordering of events. If this is the case, the processor must ensure these events are sent to these handlers in that specific order. Axon uses the SequencingPolicy
for this. The SequencingPolicy
is essentially a function, that returns a value for any given message. If the return value of the SequencingPolicy
function is equal for two distinct event messages, it means that those messages must be processed sequentially. By default, Axon components will use the SequentialPerAggregatePolicy
, which makes it so that events published by the same aggregate instance will be handled sequentially.”
So for the same aggregate, there are multiple events. How is the order decided among them? Each message comes with a token, from what I am seeing, it just takes a timestamp, does that mean the events for the same aggregate is sorted by time they arrived? In AbstractSequencedDomainEventEntry, the globalIndex is defined as below:
@Id
@GeneratedValue
private long globalIndex;
What is the use case of this globalIndex other than functioning as a primary key in the domain event entry table? I hope it is NOT used to determine the event handling order.
Thanks for the help in advance.