We sometimes have multiple event handlers listen to the same event, both synchronous processors. With one event handler updating state in the DB, the other (e.g.) triggers some emails based on the same event. We chose this approach to have these concerns isolated, i.e. the event handler that updates the DB should not be concerned with other side-effects of the event.
However, sometimes the secondary event handler depend on the state in the DB,
so we need to impose a fixed order in which the event handlers are called.
If I understand correctly, this is possible (when using Spring), but I don’t find it mentioned in the documentations.
To impose the order we:
- annotate all involved event handlers with org.axonframework.config.ProcessingGroup (order seems only applicable within one processingGroup),
- use org.springframework.core.annotation.Order to determine priority.
Is this approach correct?
If so I think it makes sense to add this to the documentation.
We also tried this approach to order a SagaEventHandler vs a normal EventHandler, but this did not seem to work.
Is it possible to impose an order involving SagaEventHandler and EventHandler?
Thank you for your answers,