Creating a new TrackingEventProcessor every manual replay

Hi,

The event handlers in my app are using the default TrackingEventProcessor (auto configuration) with a Persisted store.

I want to expose a controller endpoint that will trigger a replay of processing group on-demand.
I’d like to know which is the better approach to do this.

  1. On every replay request I am creating a new TrackingEventProcessor with a new InMemoryTokenStore (initialized to HeadToken)
TrackingEventProcessor trackingEventProcessor = TrackingEventProcessor.builder().build();

then do the replay:

trackingEventProcessor.shutDown();
trackingEventProcessor.resetTokens();
trackingEventProcessor.start();
  1. Reuse the existing TrackingEventProcessor (the default with a persisted store)?
configuration.eventProcessingConfiguration()
  .eventProcessorByProcessingGroup(processorName, StreamingEventProcessor.class)
  .ifPresent(streamingEventProcessor -> {
      if (streamingEventProcessor.supportsReset()) {
          streamingEventProcessor.shutDown();
          streamingEventProcessor.resetTokens();
          streamingEventProcessor.start();
      }
});

I am able to make both work but I wanted to know which approach is better?

Thanks!

In the case of the first one, the handler isn’t aware it is really replaying. Thus annotations like @DisallowReplay don’t work. In the second case the processor is aware it’s replaying, and also when it’s done replaying, and processing new events again.