EventHandler trigger


I am studying Axon framework and I found the simple example. https://www.baeldung.com/axon-cqrs-event-sourcing

While I playing around, I saw a very interesting thing when I re-launch the Spring boot app.
Whenever I re-launch the app, it triggers @EventHandler in OrderedProductsEventHandler class.
It loads all events into the Map. Can somebody explain why this happen?


Are you sure you’re not just firing posts on each run via the .http file in /resources?



Of course not.

When I checked the orderId, they are always same whenever I launch the app.

I believe that what you’re experiencing is an in-memory token store.

A token store keeps track of the position in the event stream that it’s currently at. Usually you would set the token store to be in the same place as the projection (e.g.: in-memory, mysql, redis, mongodb, etc.) As you have not configured JPA or other persistent stores, it’s defaulting to the in-memory version. The in-memory token store is re-created everytime your application stops, therefore it re-processes all the events when it restarts.

Thanks for the explanation.
So, event handler gurantees the persistent model changes. It’s smart!