Error Replaying when multiple application instances running: Unable to claim token 'com.sample.query[0]'. It is owned by 'xxx'

I am trying to replay few events to rebuild my projection using the events replay api.

processingConfiguration.eventProcessor(processorName, StreamingEventProcessor.class)
                               .ifPresent(streamingProcessor -> {
                                   // shutdown this streaming processor
                                   streamingProcessor.shutDown();
                                   // reset the tokens to prepare the processor
                                   streamingProcessor.resetTokens(resetContext);
                                   // start the processor to initiate the replay
                                   streamingProcessor.start(); 
                               });

While resetting the token I get this exception:

Unable to claim token 'com.sample.query[0]'. It is owned by 'xxx'

There are multiple instances running for this application. It works when I only have 1 instance of the application running.

Does the events replay api support replaying with multiple running application instances?

You will have to stop this particular event processors(all instances of it) before the reset can be done. You will continue to get the above exception till the time all instances of this particular event processor is stopped.
Event replay will support with multiple instances of the application running but you need some mechanism to stop the particular event processor across all instances.

I’m playing around with a script to stop the processors in all other instanes of the app before running the replay.
Thank you Ashwini!

hi @art_of_war,

I believe this repo can help you to understand it better!

In essence, the instance that ‘owns’ the token should be the one resetting it.
In case the first instance fails to reset it, you can try the second one and it should work =)

Or have a look at the repo I mentioned, there are more options.

KR,

I will have a look at that repo.
Thanks @lfgcampos !

1 Like