Dear Axon community,
we are using an event-sourced aggregate on Axon 4.0.2 and have used the EventMultiUpcaster for generating more fine-grained domain events from an initial event (sequence number 0) that actually creates the aggregate. The unit tests for the upcasters work as expected and nicely generate the new Stream. In our event store, there are already 3 events stored after the creation event, with sequence numbers 1, 2, and 3.
However, while loading the aggregate state from the event store only the first event from the upcasted stream is applied. All other upcasted events are ignored.
A closer look at the IntermediateRepresentation objects revealed that they are all sharing the same sequence number (0) as the original event they were upcasted from. Having found this discussion in the Google group and the related issue on Github, I am wondering whether this is a desired behavior, because the ConcatenatingDomainEventStream should be able to deal with this situation?
Understanding Steven’s comment from the discussion, modifying the sequence numbers in the intermediate representations is an anti-pattern, which totally makes sense. According to the JavaDoc of the ConcatenatingDomainEventStream:
DomainEventStream implementation that concatenates multiple streams, taking into account that some sequence numbers may appear in more than one stream.
Streams are consumed in the order provided, skipping events that have sequence numbers equal or lower than the last sequence number consumed from the previous stream.
Now, if we would modify the sequence numbers in the upcasted stream, we’d skip events with sequence numbers 1, 2, and 3. Our business logic requires that all upcasted events need to be consumed by the aggregate in the order they are generated from even 0, before consuming the next “real” event. We do not have the problem in our read-models, since the events are published on the event bus and the EventHandler implementations correctly pick them up.
Any thoughts on how to resolve the problem are highly appreciated!
Thank you and best wishes,