Replay events with criteria

Hi Axon users,

I got involved in an old project that uses Axon 2. We now want to migrate it to Axon 4.

The project has a functionality that replays all events for a certain aggregate with a certain identifier. With Axon 2 was it like this:


public void replayEventsForAggregate(final String aggregateIdentifier,ReplayingCluster replayCluster){
final Criteria criteria = getCriteriaThatListAllEventsForAggregate(aggregateIdentifier,replayCluster);

private Criteria getCriteriaThatListAllEventsForAggregate(final String aggregateIdentifier,
final ReplayingCluster replayCluster) {
return replayCluster.newCriteriaBuilder()


I understand we in Axon can replay events using TrackingEventProcessor and use ProcessingGroup to only trigger certain aggregate.

But are there any similar way to set criteria for the events like above (see newCriteriaBuilder)?
Does Axon have a best practice on this?

Thanks in advance for your help.


Hi Theis,

we didn’t port this exact same functionality to Axon 4. Axon 4 doesn’t have the same notion of replays as Axon 2 did. That is because it will simply “reset” the tracking position to the beginning of a Stream. It will then just process events from that point forward.
Also, Axon 4 will automatically skip events it doesn’t need to process. If you use AxonServer (>= 4.2), it will automatically blacklist these events as well, so that AxonServer stops sending them to the client.

If you want to explicitly open a stream with only certain events, there is no way currently other than reading the stream (and optionally blacklisting them). We have been discussing re-introducing this feature in some form, but haven’t gotten to it yet.

Note that retrieving events for an aggregate can be done using EventStore.readEvents(aggregateIdentifier, 0). The 0 parameter forces Axon to start with the first event, rather than attempting to load a snapshot. You can then pass these events to you handler if you wish to replay.

Out of curiosity, what is the reason you want to ad-hoc replay events for a specific aggregate?

Kind regards,


Hi Allard.
Thanks for your reply. I will look into using EventStore.readEvents()
But I’m concerned of the performance of doing so.