EventHandler that simply handles all events


I was wondering whether it is possible to define an EventHandler that simply handles all possible events.

E.g. instead of defining:

public void on(BankAccountCreatedEvent event) {
    repository.save(new BankAccountEntry(event.getId(), 0, event.getOverdraftLimit()));


I would like to have:

public void on(Object event) {

Is this possible?

It should work according to the docs (https://docs.axonframework.org/v/3.0/part2/event-handling.html#defining-event-handlers).

That would be great, but when using “Object”, the EventHandler simply doesn’t get called at all :-/ .

I’m using Axon 3.0.6.


it should definitely work with Object. However, note that if your class has other handlers as well, only the most specific one is actually invoked.
Alternatively, you can also define a parameter of type EventMessage<?>. That will also be invoked for all events, but doesn’t force deserialization unless you use the payload.



I am seeing the same thing here. Also using 3.0.6.

-Svein Arne

Seeing same thing == “working” or “handler not being invoked” ?

Same thing for me means it is not being invoked. Using the code below and then registerEventHandler through EventHandlingConfiguration.

public class EventAggregator {
public List Events = new ArrayList();

public void handle(Object event) {

Are you using Spring Boot Devtools? We’ve seen issues with that before where classes were loaded using different classloaders, so that Class and Class would not be assignable to each other.

You can debug this by setting a breakpoint in the AnnotationEventListenerAdapter.handle(EventMessage) method. Probable the “canHandle” invocation returns false, because the payload of the message isn’t assignable to Object.


No and I am running this from a unit test which is initialized using this:

Configurer config = DefaultConfigurer.defaultConfiguration();
config.configureEventStore(conf -> eventStore);
EventHandlingConfiguration eventHandlerConfig = new EventHandlingConfiguration();

config.registerCommandHandler(c -> new TodoItemCommandHandler(new Repository©));
eventHandlerConfig.registerEventHandler(conf-> new TodoItemEventHandler());
eventHandlerConfig.registerEventHandler(conf -> new EventAggregator());

axon = config.buildConfiguration();

Sorry for wasting your time this was all my own doing as a result of “new Repository©”.

I switched to

  public void on(EventMessage<?> message) {

sendEventToClient(message, message.getIdentifier());

since this fits more the needs I had. But this method wasn’t called, too.
And as Allard pointed out - this was a side effect of using Spring Boot Dev-Tools!

Too bad that the tools don’t work with axon.

Once more - thanks for your help!


Spring Boot DevTools uses class loading tricks to do the reloading. There is configuration in place to make it work with Axon, but there is always an edge case where things don’t work as expected. We’ll try to look into it.