Do Sagas run as normal Spring beans

Hi,

we face a weird problem. I want to use spring AOP around the sage for some extended logging.

Looking at the annotations seems to me that a Saga is also a normal Spring bean. But my aspects do not work.

An I missing something here?

Best, Michael

Hi Michael,

If you want to provide extensive logging in a Saga, I would not go for Spring AOP.
I would rather use the blocks provided by Axon to tie in to the message handling loop.

Look at the MessageDispatchInterceptor to add logging just before dispatching any message.
Similarly, the MessageHandlerInterceptor can be used to add logging just before handling a message (thus just prior to entering the message handler annotated method).
As off Axon Framework 4.2 (to release soon) you can leverage the LoggingInterceptor which Axon Framework for both purposes.
If you are using a lower version of Axon, the LoggingInterceptor can only be used as MessageHandlerInterceptor.

If you want to do very specific logging on @SagaEventHandler annotation, I’d suggest to look at this issue created by Steven Grimm.
In short, you can draft up a HandlerEnhancerDefinition/MessageHandlingMember to provide detailed logging for you (the reference guide also has a topic on this).

Any how, as you have noticed, a Saga is not a normal Spring Bean.
Hope this helps you out!

Cheers,
Steven