Axon 3.x to 4.x Saga configuration with EventProcessingStrategy

116 views
Skip to first unread message

Steven Weber

unread,
Jul 13, 2020, 11:36:08 AM7/13/20
to Axon Framework Users
We're in the process of transitioning from Axon 3 to 4 and aren't quite sure how to configure our event processing strategy for Sagas.  While most of the upgrade issues have been resolved through various forums, google foo, and source code trolling, finding the equivalent for the SagaConfiguration.subscribingSagaManager with an EventProcessingStrategy is proving challenging.

 
 
public
static <S> SagaConfiguration<S> subscribingSagaManager(
           Class<S> sagaType,
           Function<Configuration, SubscribableMessageSource<EventMessage<?>>> messageSourceBuilder,
           Function<Configuration, EventProcessingStrategy> eventProcessingStrategy);



We currently configure our saga(s) beans in the following manner in order


 
@Bean
 
public SagaConfiguration<ActivityMonitorSaga> activityMonitorSagaConfiguration(
     
SpringAMQPMessageSource eventSource,
     
@Qualifier(...) Executor executor) {

   
return SagaConfiguration.subscribingSagaManager(
       
ActivityMonitorSaga.class, c -> eventSource,
        c
-> new AsynchronousEventProcessingStrategy(executor,
           
SequentialPerAggregatePolicy.instance()));
 
}

 
@Bean
 
public SagaConfiguration<LicenseMonitorSaga> licenseMonitorSagaConfiguration(
      SpringAMQPMessageSource
eventSource,
     
@Qualifier(...) Executor executor) {

   
return SagaConfiguration.subscribingSagaManager(
       
LicenseMonitorSaga.class, c -> eventSource,
        c
-> new AsynchronousEventProcessingStrategy(executor,
           
SequentialPerAggregatePolicy.instance()));
 
}


 
...


 
@Saga(sagaStore = "cachingSagaStore")
 
class ActivityMonitorSaga { ... }


 @Saga(sagaStore = "cachingSagaStore")
 
class LicenseMonitorSaga { ... }
 

 
What is the proper way to configure a Saga with an EventProcessingStrategy in Axon 4? Your help is much appreciated and many thank yous in advance.

Steven van Beelen

unread,
Sep 16, 2020, 5:17:36 AM9/16/20
to Axon Framework Users
Hi Steven,

When making the move from Axon 3 to 4, we have taken a different stance on the SubscribingEventProcessor.
Firstly, we removed it's default status, giving that over to the TrackingEventProcessor.

Secondly, we feel the SubscribingEventProcessor should mainly be used for synchronous processing, providing you the means to update a model in the same thread publishing the event.
This can for example be necessary when you hit Set Validation issue and require to have a small data model next to your Aggregates to validate the set.
Using the SubscribingEventProcessor here is key to make sure that model is updated with the uniqueness data in the same transaction as the event is published in.

When it comes to asynchronous processing, we feel the Tracking Event Processor really should be the way to go.
Having said all that, this change has not been cemented completely yet, as the EventProcessingStrategy is still there.
Reasoning for this is that we needed to give this a think as well and as such, we still left it in.

So, my recommendation here would be to use Tracking Event Processors for your Sagas.
If you desire to still use Subscribing Event Processor, then the only way to adjust the EventProcessingStrategy currently is by invoking the SubscribingEventProcessor.Builder manually to build the entire processor yourself.

Trusting this will help you further Steven.

Cheers,
Steven

PS. It is important to note that this mailing list will be discontinued as specified in this thread.
The thread also specifies where to look further for help when it comes to Axon as soon as this mailing list is closed.

--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/axonframework/0a970157-8a28-4f6e-90a3-1f349908ecc8o%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages