Search code examples
axon

Detect if Axoni Framework has finished processing historic events from the Event Store


I am using the Axon Framework utilizing an in memory token store, which means every time I start my application all the events are loaded from the Event Store to re-create my in memory model.

This works fine for our use case, but we also would like to have a separate process that queries this model to perform some action, however, this Thread should only start execution AFTER all the historic events in the event store have been played and made the model up-to-date.

I could naively set a delay before starting the thread to give enough time for AXon to load the historic events and become up-to-date after x time, but x is a moving target as events grow and likely to be x+1 at some point.

I'm curious to know if there is a mechanism in Axon that I could use that would tell me when Axon has finished processing all the events in my query model some time after boot-up? Perhaps where the latest event timestamp is close to the current timestamp, or if there is some other way of solving this problem that I should be looking into.

Cheers


Solution

  • Axon Framework exposes some meaningful information on Token Position that can help you to implement such a control.

    Please refer to this reference-guide page

    https://docs.axoniq.io/reference-guide/operations-guide/production-considerations/monitoring-and-metrics#event-tracker-status

    in particular isCaughtUp() method can be used.

    Please also note down and track progress on this issue https://github.com/AxonFramework/AxonFramework/issues/1338

    aiming to implement that with 4.4 , will give you the option to hook into the listener and add your own logic.

    Hope this help,

    Corrado.