Replay events automatically

I have a spring boot application with axon server, when i restart the application i noticed that all the events replay automatically, so my question is why the events replay automatically and how can i stop them (it means when i start the application i don’t want the events to replay) ?

Hi Rayen

You probably don’t have any relational database connected to you application yet. If so, by auto configuration that database would be used as token store. The mongo extension also offers a token store, when MongoDB is used.

By default an in memory token store is used. Also by default, each streaming event processor will start from the beginning, when no token can be found. If you want to know more about token stores and their relation with event processors, you can read the reference guide.

My question to you is how do you know Axon is replaying events?

If you don’t have Axon configuration (in Java or yml) to process classes annotated with @ProcessingGroup and if you don’t have any methods annotated with @EventHandler, Axon should not play any events. Make sure you check the 2 annotations listed above in your code.

Also Axon event can be setup in application.yml so check there as well.

Hi,

on every package containing classes with methods annotated with @EventHandler the Axon Spring Boot Starter will initialize a so-called event processor. The package of the class becomes its processing group (optionally, you can annotate @ProccessingGroup("id") on your event processor). Having said that you can configure the behaviour of the processors (responsible for the processing groups).

Especially, you can configure if the processor starts automatically and where in event stream it starts. For example Saga processors by default start at the tail of the stream and don’t replay any events. Ordinary processors fetch their position from the TokenStore and start there. The default for a TokenStore if not connected to any DB is in-memory and this results in starting from the head of event stream and replaying of all events.

Check the section in docs:

Cheers,

Simon