Migrating from subscription event processor to tracking event processor

Viewed 76

So we are slowly trying to migrate to tracking processors. As part of that we created a new processing group for a new event that writes to Elasticsearch and set that to use the tracking processor (default is subscription).

Everything works fine from now onwards. But there are a whole bunch of events that were generated in the past that I want the new processing group eventhandler to process.

I took a look at the token_entry table but not too sure how to reset it.

For example this seems to be the token (blob) as a string

<org.axonframework.eventhandling.GlobalSequenceTrackingToken><globalIndex>1794</globalIndex></org.axonframework.eventhandling.GlobalSequenceTrackingToken>,<org.axonframework.eventhandling.GlobalSequenceTrackingToken><globalIndex>22966</globalIndex></org.axonframework.eventhandling.GlobalSequenceTrackingToken>,<org.axonframework.eventhandling.GlobalSequenceTrackingToken><globalIndex>22966</globalIndex></org.axonframework.eventhandling.GlobalSequenceTrackingToken>,<org.axonframework.eventhandling.GlobalSequenceTrackingToken><globalIndex>22966</globalIndex></org.axonframework.eventhandling.GlobalSequenceTrackingToken>

Preferably would like to reset this manually.

1 Answers

To reset a StreamingEventProcessor, like the TrackingEventProcessor (TEP), you can invoke the StreamingEventProcessor#resetTokens method on the right instance.

To find the right instance, you can use the EventProcessingConfiguration#eventProcessor(String, Class) method to retrieve an Optional containing the EventProcessor. If you provide TrackingEventProcessor.class for the' Class' parameter, the framework will automatically cast it to a TEP instance.

Although you could also adjust the stored TrackingToken directly, this isn't recommended. If you change it in the database, then the framework doesn't know you are doing a replay. Hence, you'd lose the benefits of Axon's Replay API. You can check out the Reference Guide on the subject here, by the way.

Related