Hi All, i’m trying to set up a simple @EventHandler with Spring 4 annotations and i’m not able to receive event into the EventHandler when i trigger a command.
The command is triggered , then i do a apply into the aggregate, the @EventSourcingHandler is triggered but i have a @EventHandler listening to that event and it not called,
I have try to debug the code source for 3 days and i could make it work. I suspect that my agregate repository is not set up properly but i can’t figure out how to do it with spring 4
Any help will be very nice !!!
there is my configuration :
@Bean @Lazy(false)
public CommandBus commandBus() {
SimpleCommandBus commandBus = new SimpleCommandBus();
return commandBus;
}
@Bean @Lazy(false)
public EventBus eventBus() {
return new SimpleEventBus();
}
@Bean @Lazy(false)
public AnnotationEventListenerBeanPostProcessor annotationEventListenerBeanPostProcessor() {
AnnotationEventListenerBeanPostProcessor processor = new AnnotationEventListenerBeanPostProcessor();
processor.setEventBus(eventBus());
return processor;
}
@Bean @Lazy(false)
public AnnotationCommandHandlerBeanPostProcessor annotationCommandHandlerBeanPostProcessor() {
AnnotationCommandHandlerBeanPostProcessor processor = new AnnotationCommandHandlerBeanPostProcessor();
processor.setCommandBus(commandBus());
return processor;
}
@Bean @Lazy(false)
EventStore eventStore() {
FileSystemEventStore eventStore = new FileSystemEventStore(new SimpleEventFileResolver(new File(“data/evenstore”)));
return eventStore;
}
@Bean(name = “commandGateway”) @Lazy(false)
public CommandGateway commandGateway() {
// the CommandGateway provides a friendlier API to send commands
CommandGateway commandGateway = new DefaultCommandGateway(commandBus());
return commandGateway;
}