Event handler interceptor?

There's a CommandHandlerInterceptor interface one can use to wrap command handlers in additional behavior. Is there something similar for event handlers, specifically saga event handlers?

My use case: I'd like to wrap my saga event handlers in an interceptor that adds the saga's identifier and/or the event's association value to the logger's diagnostic context and removes it when the event handler finishes. I'd also like to record/log the payloads of any events whose handlers throw exceptions.

Obviously this can be done in the event handlers themselves, but that muddies up the code. I can also do it with AspectJ or something similar (which is my current plan) but I figure it's worth making sure there's no native Axon support for it already.

-Steve

Hi Steve,

in Axon 3, we have introduced the concept of MessageHandlerInterceptor, where T is the type of message expected. All messaging components that handle messages, regardless of their type, allow the registration of these handlers.
Unfortunately, Axon 2 doesn’t have this mechanism. What you can do there, is wrap the handling component (Cluster or SagaManager) in an implementation that processes the messages as they come in. Or AspectJ…

Cheers,

Allard