【问题标题】:How do I configure Event Processors in Axon with Spring?如何使用 Spring 在 Axon 中配置事件处理器?
【发布时间】:2018-12-03 16:00:27
【问题描述】:

显然 Axon 默认使用TrackingEventProcessors。我想改用SubscribingEventProcessorsdocsthe latter is already the default,但它们似乎已经过时了。

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

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

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

但是,v4 中没有 EventHandlingConfiguration(在 v3 中有)。

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

【问题讨论】:

    标签: event-handling axon


    【解决方案1】:

    这方面的事件处理器可以在application.yml/application.properties进行配置

    axon:
      eventhandling:
        processors:
          NAME_OF_THE_PROCESSOR:
            mode: subscribing
    

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

    您可以将所有事件处理器构建器配置为使用 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

    最好, 伊万

    【讨论】:

    • 谢谢!不过,您是否在 v4 中找到了EventProcessingConfigurer?这就是我最初尝试过的,只能在 v3 中找到这样的类。我想一次配置所有个处理器。
    • EventProcessingConfigurer 是新 API - v4
    • EventHandlingConfiguration 是旧 API - v3。它在 v4 中不可用
    • 文档将被更新。 “指南”回购中有一个开放的拉取请求:github.com/AxonIQ/reference-guide/pull/25
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-27
    • 2020-08-05
    • 1970-01-01
    • 2014-02-22
    • 1970-01-01
    相关资源
    最近更新 更多