[Axon 3.3.2] Replay Events API, @ResetHandler not called

337 views
Skip to first unread message

Jérôme M.

unread,
Jul 24, 2018, 5:18:46 AM7/24/18
to Axon Framework Users
Hello,


I'm trying to trigger a replay of the events from a Tracking Processor  ( Axon 3.3.2, Spring Boot 2.0.3)

Here is my configuration  :

@Inject
 
public void configure(EventProcessingConfiguration configuration) {
   
    configuration
.registerTrackingEventProcessor("foo.test.replay",
       
(conf) -> TrackingEventProcessorConfiguration.forParallelProcessing(4));

}

The related Event Handler attached to this processor:

@AllowReplay
@Component
public class Replayer {


 
private int count;
 
 
@EventHandler
 
public void on(DomainEventMessage<?> message, ReplayStatus replayStatus) {
   
System.out.println("Thread=" + Thread.currentThread().getId() + ", events replayed=" + ++count);

 
}


 
@ResetHandler()
 
public void onReset() {
   
System.out.println("Reset Handler called !");
 
}

}

And finally this is how I trigger the replay process :

eventProcessingConfiguration.eventProcessor("foo.test.replay", TrackingEventProcessor.class)
       
.ifPresent(eventProcessor -> {

          eventProcessor
.shutDown();
          eventProcessor
.resetTokens();
          eventProcessor
.start();
       
});
}

So far, so good, the replay process is working but what I notice is that the onReset() is not called as it should be when I call resetTokens() on the EventProcessor.

After investigating a bit further, I notice that the call of the method annotated with @ResetHandler is triggered by a call to EventHandlerInvoker::performReset. By default, it does nothing.

Now, this interface has three implementations : SimpleEventHandlerInvoker, MultiEventHandlerInvoker, and AbstractSagaManager.

For the SimpleEventHandlerInvoker, the performReset() is correctly implemented, by basically looping over all the EventListener.

But in my case, the Replayer event handler is attached to a MultiEventHandlerInvoker (I don't know why actuallly, but this is part of the Axon internals), which doesn't override the default implementation of performReset().

The obvious solution I have in mind is to implement it and delegate to all embedded EventHandlerInvoker, but before submitting a PR, I would like to validate with you my understanding of the issue.

Is this the right way to use the Replay feature ?

Cheers,
Jerome

Steven van Beelen

unread,
Jul 24, 2018, 5:33:06 AM7/24/18
to axonfr...@googlegroups.com
Hi Jérôme,

Great observation and thanks for pointing out this issue!
If you would be open to creating a PR to adjust the MultiEventHandlerInvoker to override the default behavior, that would be much appreciated.
I would like to point out that the PR should perform the `supportsReset()` call on each `EventHandlerInvoker` prior to performing the `performReset()` call on it.

From the snippet you've shared I assume you are using the Replay functionality as intended by the way.
So no worries in that space so far.

By the way, if a PR doesn't fit in your schedule, an issue documenting this would also be very beneficial to us. :-)

Cheers,
Steven


--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jérôme M.

unread,
Jul 25, 2018, 7:45:25 AM7/25/18
to Axon Framework Users

Ok, thanks ! I'll do it this week-end.

Cheers,
Jerome
Reply all
Reply to author
Forward
0 new messages