Asynch event processing and Sagas

60 views
Skip to first unread message

JeffR

unread,
Oct 2, 2017, 7:12:37 PM10/2/17
to Axon Framework Users
Hi Allard,

To implement async event processing, I've configured an async cluster as shown in config snippet below:

  @Bean
 
public EventBus eventBus(ClusterSelector clusterSelector,
     
EventBusTerminal eventBusTerminal) {


   
return new ClusteringEventBus(clusterSelector, eventBusTerminal);
 
}


 
@Bean
 
public ClusterSelector clusterSelector(
     
@Qualifier("asyncExecutor") Executor executor) {
   
// Create an event bus that dispatches events asynchronously, using multiple
   
// threads, while guaranteeing that events for each aggregate ID are
   
// dispatched to listeners in the order of their production.
   
Cluster cluster = new AsynchronousCluster(queueName + QUEUE_UNIQUIFIER,
        executor
, new SequentialPerAggregatePolicy());


   
return new DefaultClusterSelector(cluster);
 
}


I will also be implementing a Saga, so a few questions:

1) With the AysnchronousCluster, do I need to configure an AsyncAnnotatedSagaManager or an AnnotatedSagaManger?
2) Do I need to configure a transaction manager for the async event handling or async saga handling?

Regards,
Jeff

Allard Buijze

unread,
Oct 6, 2017, 4:03:40 AM10/6/17
to Axon Framework Users
Hi,

1) if your cluster is already asynchronous, it is not required to also make your SagaManger asynchronous. You could, but it would just add additional thread-handoffs. Performance tests should point out if it is required.
2) If you event handlers require a transaction to do their work, then yes, you should configure a transaction manager on the async cluster. JPA, for example, won't work nicely unless there is a transaction active.

Hope this helps.
Cheers,

Allard


Op di 3 okt. 2017 om 01:12 schreef JeffR <jeff....@gmail.com>:
--
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.
For more options, visit https://groups.google.com/d/optout.
--
Reply all
Reply to author
Forward
0 new messages