Replaying event handlers

I can’t seem to find how to do a replay with axon 3, all examples I find online point to axon 2 examples. Can someone point me in the correct direction?


I’ve experimented with replaying events to query model (ORM) handlers, for the scenario where a query model database migration might not be possible.

  • I use Spring to inject all my query model handler objects, which implement the QueryModelUpdater interface
  • I create a new temporary Axon configuration that just has the query model updater handlers registered
  • I read all the events from my app’s mongodb event store and publish them to the event bus for the new Axon configuration

Not sure if this is the best approach but it seems to work.

List queryModelUpdaters;

private EventStorageEngine eventStore;

EventHandlingConfiguration ehConf = new EventHandlingConfiguration();
for (QueryModelUpdater queryModelUpdater : queryModelUpdaters) {
System.out.printf(“Registering replay event handler %s\n”, queryModelUpdater.getClass().getSimpleName());
ehConf.registerEventHandler(conf -> queryModelUpdater);

Configuration config = DefaultConfigurer.defaultConfiguration()
EventBus replayEventBus = config.eventBus();
this.eventStore.readEvents(null, false).forEach(msg -> {
System.out.printf(“Replaying %s\n”, msg.getPayload().getClass().getSimpleName());



replays have been redesigned in Axon 3. Instead of doing a ‘replay’, you can configure groups of Event Handlers (so called processing groups) to be assigned to a TrackingProcessor. The TrackingProcessors track the events in the Event Store and keep track of where they are. By default, they start from the beginning.
To force a replay, you would clear the token for such a processor as well as any query models it creates. When the processor starts, it will replay all events and automatically continue processing as events come in.

Check the reference guide on how to configure processors.

Hope this helps.



Thanks for the replies. I’ve read through the event processing guide and also playing a bit with the API.

  1. It seems that when using TrackingEventProcessor it’s not possible to provide ProcessingStrategy in order to provide a SequencingPolicy?
  2. It also there seems to be an assumption that the event processing needs to happen in a singleton application in the cluster, is that right? If not how would you suggest to adapt the infrastructure to support spreading the event handling to a cluster?


Hi Mauricio,

  1. That’s correct, but is a thing being worked on. The ProcessingStrategy and SequencingPolicy are part of running multi threaded, something the TrackingEventProcessor does not support yet. This issue will, as said, solve this and should introduce the ProcessingStrategy and SequencingPolicy. It’ll come in Axon 3.1, which you should expect somewhere in the upcoming two months.
  2. I think some additional TrackingEventProcessor background might clear this up. What a TrackingEventProcessor for a certain ProcessingGroup does, is try to load or create a TrackingToken for it’s group prior to it handling events. That means, that if you’ve got several identical applications running in a cluster (so all with the same TrackingEventProcessor group) that they’ll compete over locking the TrackingToken. So, ‘event processing doesn’t need to happen in a singleton application in the cluster’, but it is what it’s doing right now. Again, the issue I’ve linked will adjust this, such that a TrackingToken is separated in segments, within which a segment will point to a certain set of events in the EventStore.

Hope this answers your questions Mauricio! :slight_smile:
I think in short; Axon 3.1 should lift some of these ‘concerns’ of yours.