I’m using axon-spring-boot-autoconfigure, and I want to register an EventLoggingInterceptor. To do that I’d like to define my own EventBus, but I can’t work out what’s the right way of doing it.
AxonAutoConfiguration contains the following. Note that I configured my own EventStorageEngine.
`
@Qualifier(“eventStore”)
@Bean(name = “eventBus”)
@ConditionalOnMissingBean(EventBus.class)
@ConditionalOnBean(EventStorageEngine.class)
public EmbeddedEventStore eventStore(EventStorageEngine storageEngine, AxonConfiguration configuration) {
return new EmbeddedEventStore(storageEngine, configuration.messageMonitor(EventStore.class, “eventStore”));
}
@Bean
@ConditionalOnMissingBean({EventStorageEngine.class, EventBus.class})
public SimpleEventBus eventBus(AxonConfiguration configuration) {
return new SimpleEventBus(Integer.MAX_VALUE, configuration.messageMonitor(EventStore.class, “eventStore”));
}
`
I have to define both to get the app to start, but when I try to do:
`
@Bean
public EmbeddedEventStore eventStore(EventStorageEngine storageEngine, AxonConfiguration configuration) {
return new EmbeddedEventStore(storageEngine, configuration.messageMonitor(EventStore.class, “eventStore”));
}
@Bean
public SimpleEventBus eventBus(AxonConfiguration configuration) {
SimpleEventBus eventBus = new SimpleEventBus(Integer.MAX_VALUE, configuration.messageMonitor(EventStore.class, “eventStore”));
eventBus.registerDispatchInterceptor(new EventLoggingInterceptor());
return eventBus;
}
`
I see the following in the log: SpringAxonAutoConfigurer : Multiple beans of type EventBus found in application context: [eventStore, eventBus]. Chose eventStore
What is the right way to do this?