Events are replayed on startup (dev environment)

Hi,

I am testing the axon framework and I am facing with a couple of challenges:

1st when sending commands to a command gateway’s aggregate I’m seeing tha the Aggregate is created over and over and the previous commands/events are played again, it is like (on the example I will use c for command and e for events and a for aggregate)

  • c1 generates e1 that is for a1
  • c2 generates a e2 that is for a1. (if I debug the aggregate on this step I’m seeing c1 -> e1 -> c2 -> e2

2nd when I do restart my server the events on the @eventHandler annotated methods are replayed every time, is it normal? I have annotated them with the @AllowReplay(false), and it is repeated.

Thanks in advance!

Hi,

for the latter problem i would assume that you did not explicitly configure a persistent TokenStore in your application’s configuration, which means that your application holds the actual processing position in the event stream for each event processor in memory and loses this state on application exit.

From the Axon Documentation (https://docs.axoniq.io/reference-guide/configuring-infrastructure-components/event-processing/event-processors#token-store):

The Configuration API takes the token store, as well as most other components processors need from the global configuration instance. If no token store is explicitly defined, an InMemoryTokenStore is used, which is not recommended in production.

If you like to persist the processing position in the event stream you need to configure a persistent Token Store (JPATokenStore, JDBCTokenStore). Also you should consider a persistent SagaStore if you use Sagas. See also this discussion here regarding setup:

Best Regards,
Jakob

Hi Jacob,

Thanks for the answer, that was the “thing” missed, I think I did not found this setup on the different examples and that made me to get this wrongly defined.

Regards.