Event Processing (Sending/Receiving) Order Guarantees???

Hey there,

I have a simple question and I am fairly certain that the answer is yes, but I would like to bounce it off the members of the forum. I have a slight concern about the order in which events are processed by EventHandlers that are running in separate JVMs and I am wondering how and if order is guaranteed. For instance I have an aggregate root that can have actions that create, modify, and confirm this aggregate. Upon change of the aggregate state events are broadcasted to various event handlers some of which are not within the same JVM. My question is, will Axon guarantee the order in which the events are spawned is the same order in which they are received by an observing JVM (processed is a different question)

A simple use case is shirt ordering where a user buys a yellow shirt and then changes the color and then confirms the order which prevents further change.

pseudo Code

new Order( new Shirt( “Yellow” ) )
-> apply( OrderCreatedEvent( “Yellow”))

Order.swapShirt( new Shirt( “Red” ))
-> apply (OrderChangedEvent( “Red” ))

Order.confirm()
-> apply( OrderConfirmedEvent )

The assumption with this use case is that these events happened after 3 separate commands were issued to the JVM. I can see that within a JVM this is fairly straightforward, these events are played in the order that they have been received, but for other nodes listening on a distributed event bus I am not sure that the order will be preserved especially if these events happen quickly. Unlike Commands that have a TargetAggretIdentifier, Events don’t have a similar aggregate locking concept. Any thoughts?

-Carlyle
P.S. Sorry for the silly example just wanted to add a bit of context.

Hi Carlyle,

apparently, your previous email was cut off. I responded to that one here: https://groups.google.com/d/msg/axonframework/EAMsX8OTE5A/LF5jUuQL-JcJ

If you have 3 commands handled on 3 different machines, the optimistic locking mechanism on the event store will eventually kick in, as two machines will attempt to insert events with the same sequence number. The Event Store should (and will) not accept that. In other words, ordering in this scenario is always guaranteed. When commands are handled on the same VM, Axon will use locks to order the commands.

Cheers,

Allard