In our application, we intentionally made a distinction between domain
and application events, the former relating to events that update the
state of aggregates, the latter containing calculated totals that need
to be relayed to the query side.
We stumbled upon some nasty timing issues, caused by the application
events always being put on the event bus first before the domain
events are being published. This implies that the totals relate to
data that are not yet present on the query side.
Looking at the implementation of the Axon framework, we concluded that
it is not possible to maintain the order between application and
domain events, the former always being put on the event bus first.
Is there any reason for this behavior? As far as we can tell, this
behavior can be quite misleading, as application events that are
seemingly put on the bus last in the code (in the aggregate), are in
fact put on the bus first, since the domain events are buffered in the
aggregate and are put on the bus last by the repository.
If there is no such reason, perhaps it would be useful to consider to
implement an apply() method accepting application events as well?