这可能是由于您的Axon配置中缺少'SubscribingEventProcessor”的原因。在您的Axon配置中的'EventHandlingConfiguration”上添加以下代码行:
@Configuration public class AxonConfig {
@Bean
public SubscribingEventProcessor subscribingEventProcessor(EventStore eventStore, EventBus eventBus,
ErrorHandler errorHandler) {
return SubscribingEventProcessor.builder()
.name("subscribingEventProcessor")
.eventHandlerInvoker(eventBus)
.eventStore(eventStore)
.errorHandler(errorHandler)
.build();
}
}
这将确保所有服务实例都会收到Axon事件的消息。然后,在您的服务端代码中注册这个处理器:
@EventProcessingEventHandler public void handle(SomeEvent event) { // handle event }
这应该使您的Axon事件在所有服务实例中正确扇出。