Several instances and event processing


We are using tracking processors in our services.

For a particular service, we have two separate instances for high-availability. Only one of the instances is the owner of the only segment we have for the processor, meaning that only one instance is processing events. The other stays idle when it comes to processing events.

However, because of the nature of this particular service, we would like to have both instances processing all events. My question is simple, is that even possible? And if so, how?


Hi Armando,

if you have a processor for which you want each instance to handle all events, there are roughly 2 approaches to take.

A processor will lookup the tokens in the token store, using its name. If tokens exist, it will try to claim one or more. If none exist, it will initialize the configured number of segments with the initial token. This initial token is configurable, and defaults to the tail of a stream (the first event). Alternatively, you can provide “StreamableMessageSource::createHeadToken” as the initial tracking token (org.axonframework.eventhandling.TrackingEventProcessorConfiguration#andInitialTrackingToken). In that case, it will start at the “live” position of the stream, where new events are added.

That leaves two options:

  1. Have the processors (still) share a token store, but give each processor a name that includes the instance ID. This makes them unique from an Axon point of view, and each will receive all messages. Downside from this approach is that tokens aren’t removed when nodes are stopped, and may pollute our token store.

  2. Give each node its own token store, storing progress locally. In that case, both nodes won’t share information with the others. If you use an in-memory token store, for example, progress is stored until the nodes is restarted. With a “StreamableMessageSource::createHeadToken” as initial token, this means it will process live events on each restart.

Hope this helps.


Hi Allard,

Thank you very much for the detailed response. It makes sense, I’ll think about which approach fits better our needs and will give it a go!

Again, thanks!