Axon upgrade trackingEventProcessor

Hi guys,
I am upgrading from axon 3.4 to 4.1, all worked well except that I didnt have trackingEventStore before (or it was in memory not sure) but there were no configs for it, now I am adding it, the only problem is that once the app starts it starts to replay all events since the table of trackingToken is empty, how can I add some configs to not allow it replay, I am trying to configure the TrackingEventProcessorConfiguration to createTailToken but no luck to configure it with spring boot. any advices?

@Autowired
public void configureTrackingEventProcessors(EventProcessingConfigurer configurer) {
    /**
     * This is a temporary just needed for the first deployment, since we didnt have the tracking event processor
     * configured before, and now with the axon upgrade it needs to be configured, if we dont have the below configuration
     * Axon will replay all of the events in the store, so we are configuring the tracking event to have a head token
     * to create the tokens from the head of the event store
     * TODO - remove this function after deployment
     */
// I have added the list of processing groups here
    List<String> processingGroups = Arrays.asList();

    processingGroups.forEach(processingGroup -> {
        TrackingEventProcessorConfiguration trackingProcessorConfig =
            TrackingEventProcessorConfiguration.forSingleThreadedProcessing()
                .andInitialTrackingToken(StreamableMessageSource::createHeadToken);

        configurer.registerTrackingEventProcessor(processingGroup,
            config -> config.eventStore(),
            config -> trackingProcessorConfig);
    });
}

I think what was confusing for me that I used createTailToken instead of head, its a bit confusing as I understood that’s the head is the start of the events and the tail is the last one

Hi Karim,

Glad to see you’ve resolved the problem yourself too, and of course that you’ve shared your solution with everybody.
I get the misconception regarding head and tail, I’ve noticed this with others before, so don’t worry.
In essence, the head of the stream is the starting point, whilst the tail is the end.
Envision it like ‘tailing a log’, then you also get the latest piece of data (as it occurs).

Cheers,
Steven

hi Steven,
Thanks for your reply. well, that’s interesting. That means that the newest events are the tail, right?
from mongo extension there is this code:

@Override
public TrackingToken createHeadToken() {
    return createTokenAt(Instant.now());
}

that’s why I needed the HeadToken to get the most recent event and not replay all events

The API documentation has it the other way around: https://axoniq.io/apidocs/4.0/org/axonframework/messaging/StreamableMessageSource.html

The head is where events are written. Quite similar to where Git also writes, or where items are added to a queue.

The trick to remember it: events go in through the head, and come out… well… they would have come out at the tail if they weren’t stored forever :wink:

Hope it helps.
Cheers,

Allard