Ordering of event handlers with @Order

I have a question about using the @Order annotation… Say I have 2 event handler classes (Eh1, Eh2) and they both are in a single processing group with the same annotation @ProcessingGroup(“my_event_handler”):

@ProcessingGroup(“my_event_handler”)
@Order(1)
Class Eh1
on(E1,…) {
}
on(E2,…) {
}
on(E3,…) {
}
}

@ProcessingGroup(“my_event_handler”)
@Order(2)
Class Eh2 {
on(E2,…) {
}
}

When the tracking processor for processing group “my_event_handler” processing events, what is the invocation sequence for the event handlers (methods) if an aggregate has events E1, E2 and E3 fired?

a) Eh1.on(E1,…), Eh1.on(E2,…), Eh1.on(E3,…), then Eh2.on(E2,…)
b) Eh1.on(E1,…), Eh1.on(E2,…), then Eh2.on(E2,…), back to Eh1.on(E3)

I assume the event handler call sequence is a) above.
Is this something written in the documentation? I seem to have trouble finding it.

Any ideas?

Hi,

as they are configured in the same processing group, the expected order would be:
Eh1.on(E1), Eh2.on(E1)
possibly in the same transaction, maybe another one:
Eh1.on(E2), Eh2.on(E2)
etc.

Processors handle events sequentially, with the exception of events that are configured to be handled concurrently using a SequencingPolicy. The default is sequential per aggregate, which means events from the same aggregate are handled sequentially. This means that E2 will always be handled after E1.

Totally make sense especially when you mentioned about the sequencing policy “sequential per aggregate.” Thanks a million Allard!