Aggregate does not consume events with same sequence number generated by EventMultiUpcaster

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,
Phil

@Steven
@Allard

Do you have any thoughts on this issue? Is this a bug?

Thanks in advance!
Best,

Phil

We did some further debugging and found that the EventMultiUpcaster correctly produces the upcasted events, but the AxonServerEventStore#upcastAndDeserializeDomainEvent(DomainEventData) only returns the first element of the upcasted stream.
We would expect the method to return a Stream and that AxonServerEventStore#readEvents(String) takes care of correctly expanding concatenating the multi-upcasted events into a stream that can be consumed.

I could not find any tests covering this behavior, so could you please take a look at this? We are starting to wonder, whether we apply the EventMultiUpcaster correctly.

Thank you and best wishes

Hi Philipp,

I’ve found time to have a look at it. At a quick glance, it does indeed look like a bug inside the AxonServer connector. I will investigate further and get back to you.

Cheers,

twitter-icon_128x128.png

It is a bug indeed. I have filed issue 1263 ( https://github.com/AxonFramework/AxonFramework/issues/1263 ) and working on a fix right now.

Cheers,

twitter-icon_128x128.png

Hi Allard,

thanks for taking care of this so fast!

Best,
Phil