Is there a way to seek to a particular event and start processing in event handlers?

Hi all,

I am creating a new event handler to create a report. The requirement is that I start listening for certain event after a certain date which is pretty much close to the end of our 100M events. I am using the following registration for the handler:

          configurer.registerTrackingEventProcessor(processingGroup, org.axonframework.config.Configuration::eventStore,
              conf -> TrackingEventProcessorConfiguration.forParallelProcessing(projector.getMaxThreads())
                  .andBatchSize(projector.getBatchSize())
                  .andInitialTrackingToken(streamableMessageSource -> streamableMessageSource
                      .createTokenAt(projector.getEventReplayStartAt())))
              .registerHandlerInterceptor(processingGroup, configuration -> new EventHandlerLoggingInterceptor())
              .registerErrorHandler(processingGroup, conf -> projector.newErrorHandler());

This actually does the job but unfortunately it took around 12 hours to “skip” to the events that I need to process. I understand that I can use more threads and a larger batch size to process more events, but it seems to be very inefficient to have to read and skip all the events until the very end. Is there a way that you can recommend me to proceed tackling this? I was thinking if there is a way to just “skip” to a particular event (like a global event index) without reading from the start would be great.

Hi @ekyu88,

I believe the createTokenAt method that you used is actually what you are looking for.
I couldn’t deduce the value of your projector.getEventReplayStartAt() but you can probably get a better number for that and make sure you don’t “process” every event.

Check the official docs for more info: Streaming Event Processors - Axon Reference Guide

KR,

Hey Lucas,

Thank you for helping. I no longer use the createTokenAt because it does not seem to do the job. I went back and use addInitialTrackingToken(), and instantiate a GlobalSequenceTrackingToken() to identify an event to begin stream (re)play and this seems to be working the way we expect partial event replay would be.

Regards,
Ed.

To close this topic, it turns out during the configuration of the tracking processor, java reflection call from a package we used failed causing the event handling class failed to be recognized and configured to handle the events. After removing the reflection code, everything worked.