ReplayingCluster not calling BeforeReplay()

Hi,

My config:

@Bean
public EventBus eventBus() {
ClusteringEventBus ret = new ClusteringEventBus(new DefaultClusterSelector(localCluster()));
return ret;
}

@Bean
public Cluster localCluster() {
return new SimpleCluster(“local”);
}

@Bean
public ReplayingCluster replayingCluster() throws SQLException {
ReplayingCluster ret = new ReplayingCluster(localCluster(), eventStore(), new SpringTransactionManager(axonTransactionManager()), 100, new BackloggingIncomingMessageHandler());
return ret;
}

@Bean
public AnnotationEventListenerBeanPostProcessor annotationEventListenerBeanPostProcessor() {
AnnotationEventListenerBeanPostProcessor postProcessor = new AnnotationEventListenerBeanPostProcessor();
postProcessor.setEventBus(eventBus());
return postProcessor;
}

Then I have an EventListener implements ReplayAware with @EventListener annotations

Event handling works, replay works but the BeforeReplay is never called.

Am I missing something?

Geir

Hi Geir,

your event bus is configured with “localCluster” as default cluster. That means handlers are subscribed to that cluster, and not the replaying one. If you register them to the replaying one, it will see they implement “ReplayAware” and handle the before and after replay methods.

My advice would be to wrap the clusters in such a way, that only valid cluster beans exist:

@Bean
public EventBus eventBus() {
ClusteringEventBus ret = new ClusteringEventBus(new DefaultClusterSelector(myCluster()));
return ret;
}

@Bean
public ReplayingCluster myCluster() throws SQLException {
ReplayingCluster ret = new ReplayingCluster(new SimpleCluster(“local”), eventStore(), new SpringTransactionManager(axonTransactionManager()), 100, new BackloggingIncomingMessageHandler());
return ret;
}

Cheers,

Allard