I have a Bean with event handlers that I want to configure to track events in order to allow replay. For that I simply added it the ProcessingGroup annotation :
`
@ProcessingGroup(“readModelProcessor”)
public class MyReadModelEventHandler {
@EventHandler
public void handleMyEvent(MyEvent e) {
…
}
}
`
Then in a spring application, I complete my configuration with two additional methods :
`
@Configuration
public class Config {
…
@Bean
public TokenStore tokenStore(MongoTemplate mongoTemplate, Serializer serializer) {
return new MongoTokenStore(mongoTemplate, serializer);
}
@Autowired
public void configureEventProcessors(EventProcessingConfiguration configuration) {
configuration.registerTrackingEventProcessor(“readModelProcessor”);
}
}
`
and all work fine : the token is peristed in mongo database, I can replay events… Simple and efficient.
Now I need to do the same thing in an older application without spring. So I use the configuration API… and it does not work.
That’s what I did. I must miss something, but I do not know what :
MongoTokenStore tokenStore = new MongoTokenStore(mongoTemplate, new XStreamSerializer()); EventProcessingConfiguration eventProcessingConfiguration = new EventProcessingConfiguration(); eventProcessingConfiguration.registerTokenStore("readModelProcessor", c -> tokenStore); eventProcessingConfiguration.registerTrackingEventProcessor("readModelProcessor");
and I added it to my existing configuration :
`
EventHandlingConfiguration eventHandlingConfiguration = new EventHandlingConfiguration()
.registerEventHandler(c -> new AnnotationEventListenerAdapter(new MyReadModelEventHandler()));
axonConfiguration = DefaultConfigurer.defaultConfiguration()
.configureCommandBus(c -> new SimpleCommandBus())
.configureEventStore(c -> eventStore)
.configureAggregate(myAggregateConf)
.registerCommandHandler(c -> new AggregateAnnotationCommandHandler<>(MyAggregate.class, myAggregateRepository))
.registerModule(eventProcessingConfiguration)
.registerModule(eventHandlingConfiguration)
.buildConfiguration();
`
My event handlers continue to be called, but the tracking mode does not work : there is no collection in the mongodb database.
Any idea about missing part ?
Thanks.