如何使用Spring在Axon中配置事件处理器?

Dou*_*e M 1 event-handling axon

显然,Axon TrackingEventProcessors默认使用。我想SubscribingEventProcessors改用。该文档说,后者已经是默认的,但他们似乎已经过时。

默认情况下,Axon将使用订阅事件处理器。使用Configuration API的EventHandlingConfiguration类可以更改处理程序的分配方式以及处理器的配置方式。

例如,建议执行如下配置:

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

但是,EventHandlingConfigurationv4中没有(v3中有)。

我需要使用SubscribingEventProcessors来在与命令处理相同的事务中执行读取模型更新。如何在4.0中进行配置?

Iva*_*lic 5

事件处理器的这一方面可以在 application.yml/application.properties

axon:
  eventhandling:
    processors:
      NAME_OF_THE_PROCESSOR:
        mode: subscribing
Run Code Online (Sandbox Code Playgroud)

我想你是对的。文档引用了旧的API。

您可以配置所有事件处理器构建器以使用SubscribingEventProcessor

 @Autowired
 public void configure(EventProcessingConfigurer configurer) {
      configurer.usingSubscribingEventProcessors(); 
 }
Run Code Online (Sandbox Code Playgroud)

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

最好,伊万