Same event fired by multiple aggregates

I think this should work but want to clarify.

AggregateA fires sentEmailEvent then only aggregateAs event handler for this event and any other eventHandler listening to this event will intercept

AggregateB fire sentEmailEvent then only aggregateBs event handler for this event and any other eventHandler listening to this event will intercept

AggregateAs sendEmailEvent will NOT be intercepted by Aggregate B and visa versa due to the aggregateIds being different.

In Axon 1.x this was more apparent as aggregateID was built into to the domainEvent.

Will this approach still work with Axon 2.

Thanks and Cheers…

Hi,

this is exactly how it works. In Axon 2, the aggregate identifier is contained in the Message class that wraps an event. However, you should not rely on this identifier in your business logic. In other words, if you need the aggregate identifier in your application, include it in the event (payload) itself.

Cheers,

Allard