Hello,
I’m having a hard time figuring why some EventHandler is not triggered after an Event is correctly dispatched by the Axon EventBus.
Here is some relevant methods in my AxonConfiguration class :
@Autowired
public void configureEventBus(EventBus eventBus) {
eventBus.registerDispatchInterceptor(mdcDataInterceptor());
if (LOGGER.isDebugEnabled()) {
eventBus.registerDispatchInterceptor(messages -> (integer, eventMessage) -> {
LOGGER.info(">{}<", ColorizedLogs.brightViolet("Dispatching Event " + eventMessage.getPayloadType().getSimpleName()));
return eventMessage;
});
}
}
private Function<org.axonframework.config.Configuration, ListenerInvocationErrorHandler> addErrorListener() {
return configuration -> (ListenerInvocationErrorHandler) (exception, eventMessage, eventHandler) -> {
eventGateway.publish(ImmutableTechnicalError.builder()
.id(((PersistedEvent) eventMessage.getPayload()).id())
.throwable(exception)
.payload((PersistedEvent) eventMessage.getPayload()).build());
};
}
In a functionnal part of my application I have a method similar to this :
@EventHandler
public void on(MyCustomEvent event) {
store1.persist(someData);
store2.persist(otherData);
}
and another to catch technical errors :
@Override
@EventHandler
public void on(ImmutableTechnicalError technicalErrorEvent) {
LOGGER.error("Technical error event received : {}", technicalErrorEvent);
}
Now here is what happens :
- store2.persit() throws an Exception
- The exception is correctly catch by the ListenerInvocationErrorHandler.
- The event ImmutableTechnicalError is correctly dispatched by the EventBus
=> But the EventHandler for the ImmutableTechnicalError event is never triggered.
Any ideas what could cause this behaviour ?