Double M
Double M

Reputation: 1503

How do I configure Event Processors in Axon with Spring?

Apparently Axon uses TrackingEventProcessors by default. I would like to use SubscribingEventProcessors instead. The docs say that the latter is already the default, but they seem to be outdated.

By default, Axon will use Subscribing Event Processors. It is possible to change how Handlers are assigned and how processors are configured using the EventHandlingConfiguration class of the Configuration API.

For instance, it is suggested to perform configurations like so:

@Autowired
public void configure(EventHandlingConfiguration config) {
    config.usingTrackingProcessors(); // default all processors to tracking mode.
}

However, there is no EventHandlingConfiguration in v4 (there was in v3).

I need to use the SubscribingEventProcessors to perform read-model updates in the same transaction as command handling. How can this be configured in 4.0?

Upvotes: 1

Views: 2338

Answers (1)

Ivan Dugalic
Ivan Dugalic

Reputation: 661

This aspect of event processors can be configured in application.yml/application.properties

axon:
  eventhandling:
    processors:
      NAME_OF_THE_PROCESSOR:
        mode: subscribing

I think you are right. Documentation is referencing old API.

You can configure all event processors builders to use SubscribingEventProcessor

 @Autowired
 public void configure(EventProcessingConfigurer configurer) {
      configurer.usingSubscribingEventProcessors(); 
 }

https://github.com/AxonFramework/AxonFramework/blob/axon-4.0/config/src/main/java/org/axonframework/config/EventProcessingConfigurer.java#L216

Best, Ivan

Upvotes: 5

Related Questions