Publish event from non aggregate (Axon 3.0.7)

Hi all,

I want one of our saga’s to be started by both an event that is published from an aggregate, and from a certain listener that receives messages from an external source/service.

From that listener i’d like to publish an event (in stead of routing it over an aggregate using a command). This listener is obviously not an Aggregate. Is there a way to publish events directly from non-aggregates? It appears eventBus, which I believe is used before Axon 3.x, is not available anymore? What is the best alternative?


Hi Nol,

the EventBus is still present. In fact, the Event Store in Axon 3 is a more specialized implementation of the Event Bus, which doesn’t only publish messages, but also store them. If you have messages that you don’t want stored in your Event Store, but still published, you can use a wrapper around the EventStorageEngine (check out the FilteringEventStorageEngine class) to define which messages should be stored. Be careful, though: TrackingEventProcessors look at stored events, and will not receive events that have been filtered out.

In your case, just inject the EventBus into the bean that handles the other event, and publish an event based on the incoming one when appropriate.