正在处理命令端事件,但未调用查询(投影仪)。 使用轴突卡夫卡扩展4.0-RC2。
请检查以下代码参考。
AxonConfig
import org.springframework.context.annotation.Configuration;
@Configuration
public class AxonConfig {
}
application.yml
server:
port: 9001
spring:
application:
name: Query Application
datasource:
url: jdbc:postgresql://localhost:5441/orderdemo
username: orderdemo
password: secret
driver-class-name: org.postgresql.Driver
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQL95Dialect
jdbc:
lob:
non_contextual_creation: true
hbm2ddl.auto: update
implicit_naming_strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
physical_naming_strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
axon:
eventhandling:
processors:
query:
mode: tracking
source: kafkaMessageSource
kafka:
default-topic: axon-events
consumer:
group-id: query-group
bootstrap-servers: localhost:9092
答案 0 :(得分:2)
要使此配置生效,包含要调用的用于处理来自卡夫卡事件的@EventHandler
带注释函数的类需要成为处理组query
的一部分。
此要求遵循您选择的配置模式,其中“ axon。eventhandling.processors。查询”定义了您要配置的处理组。为了指定处理组,我认为最简单的方法是在事件处理类中添加@ProcessingGroup
批注。在注释中,您必须提供处理组的名称,该名称必须与您在配置文件中设置的名称相对应。
最后,我建议您为处理组使用一个不同于query
的名称。在我看来,事件处理程序更新对于查询模型而言更具体一些。
希望这会有所帮助!