Confused about Configuration in Axon 4.

Hi,

I am not able to customize tracking event processor, like below in Axon 4:

TrackingEventProcessorConfiguration
        .forSingleThreadedProcessing()
        .andBatchSize(1000)
        .andInitialTrackingToken((StreamableMessageSource::createHeadToken));


In the documentation described [here](https://docs.axoniq.io/reference-guide/configuring-infrastructure-components/event-processing/event-processors#custom-tracking-token-position) it should be possible, however I get the impression it's not the intention to 
use this when using Spring Boot Autoconfiguration. The documentation doesn't state, how to configure the initial tracking token, with
spring boot autoconfig. Properties can be used, and I works nicely for some config, but not all config is supported through properties. 
(I.e. setting the initial tracking token). Speaking of which we think the default should be the head token, not the tail. 
(A clean token store, will play all events, even annotated @AllowReplay(false) which is super dangerous in our opinion). 

I studied the code, and debugged auto-config, it really seems TrackingEventProcessorConfiguration is not intended for SpringBoot auto config [1], 
Can this be confirmed please, and maybe a hint on how to set the initial tracking token? 

Perhaps it's as simple as extending the properties, to allow the initial tracking token to be set..I personally would prefer to set these things
programmatically, so returning a configuration bean, which is used in axonautoconfig... 

Thank you Christophe

[1]  configuration is produced from properties: 

Following up on my own question, I see actually the TrackingEventProcessorConfiguration is retrieved with getComponent()
… so I need to understand how a custom component can be registered…

return trackingEventProcessor(name,
                              eventHandlerInvoker,
                              conf.getComponent(
                                      TrackingEventProcessorConfiguration.class,
                                      TrackingEventProcessorConfiguration::forSingleThreadedProcessing)

Hi Christophe,

We agree that not having the ‘tracking token initialization’ logic opened up through the Spring Boot configuration files as a miser.
As you might deduce too, head and tail logic in there is quite simple. The start-token-at-timestamp logic is however a bit more work.
I’ve just created an issue marking this feature, as I do see value in providing this.

Speaking of which we think the default should be the head token, not the tail.

I understand your point of view in this, but this is highly dependent on the nature of your application.
Having this initialize to a tail token is not only confirming to the default in Axon 3, but also how the functionality in Axon 2 which covered this topic, Clusters, dealt with the situation.
Additionally, this would impose a breaking change if we’d flip around the default, hence I do not feel this would be the best way to go.

(A clean token store, will play all events, even annotated @AllowReplay(false) which is super dangerous in our opinion).
This is intended, as the application can, in no way know whether the non-existence of that token is (1) the first start up of your application or (2) the old approach of starting a replay.

To issue a replay, we highly recommend you use the replay API present on the Tracking Event Processors.

What we could do to honor your and your teams request in some form, is to provide functionality to flip this default easily through a configuration file used in a Spring Boot scenario.
Would you view this to be a fair resolution to this pain point you’re experiencing?

Following up on my own question, I see actually the TrackingEventProcessorConfiguration is retrieved with getComponent()
… so I need to understand how a custom component can be registered…

To configure a configuration Component for an Axon application, you can use the Configurer#registerComponent(Class<C> componentType, Function<Configuration, ? extends C> componentBuilder) function.

Next to that though, the auto configuration solution in the framework still uses the regular Configuration classes you’d use if you wouldn’t do auto configuration.
Thus, there is an EventProcessingConfigurer created for you, which you can leverage to specify how your Tracking Event Processor will be started up.

In an Axon 4.0 world, you’d then have to register every Tracking Event Processor you’d want to have a specific configuration for manually.

As off Axon 4.1, which is to be released soon, you can also leverage the EventProcessingConfigurer#registerTrackingEventProcessorConfiguration method to provide a default to be used when building all your Tracking Event Processors.

Cheers,
Steven

Hi Steven,

Thank you for you swift response,
See below point by point.
Rgds C.

Hi Christophe,

We agree that not having the ‘tracking token initialization’ logic opened up through the Spring Boot configuration files as a miser.
As you might deduce too, head and tail logic in there is quite simple. The start-token-at-timestamp logic is however a bit more work.
I’ve just created an issue marking this feature, as I do see value in providing this.

Cool thank you.

Speaking of which we think the default should be the head token, not the tail.

I understand your point of view in this, but this is highly dependent on the nature of your application.
Having this initialize to a tail token is not only confirming to the default in Axon 3, but also how the functionality in Axon 2 which covered this topic, Clusters, dealt with the situation.
Additionally, this would impose a breaking change if we’d flip around the default, hence I do not feel this would be the best way to go.

(A clean token store, will play all events, even annotated @AllowReplay(false) which is super dangerous in our opinion).
This is intended, as the application can, in no way know whether the non-existence of that token is (1) the first start up of your application or (2) the old approach of starting a replay.

To issue a replay, we highly recommend you use the replay API present on the Tracking Event Processors.

Sure, we do and have put an endpoint in front for easy replay and state of the processor.
But it’s not the replay case I am worried about, it’s when token table get accidentally cleared, restarting the TEP would then simply replay events we explicitly don’t want replayed. As you correctly say, there is no way for the TEP to know the difference between a first start and an accident but it is a practical issue which requires a solution.

What we could do to honor your and your teams request in some form, is to provide functionality to flip this default easily through a configuration file used in a Spring Boot scenario.
Would you view this to be a fair resolution to this pain point you’re experiencing?

That would be great, anything really so we can configure the initial token.

Following up on my own question, I see actually the TrackingEventProcessorConfiguration is retrieved with getComponent()
… so I need to understand how a custom component can be registered…

To configure a configuration Component for an Axon application, you can use the Configurer#registerComponent(Class<C> componentType, Function<Configuration, ? extends C> componentBuilder) function.

Next to that though, the auto configuration solution in the framework still uses the regular Configuration classes you’d use if you wouldn’t do auto configuration.
Thus, there is an EventProcessingConfigurer created for you, which you can leverage to specify how your Tracking Event Processor will be started up.

In an Axon 4.0 world, you’d then have to register every Tracking Event Processor you’d want to have a specific configuration for manually.

That sounds like a lot, for simply setting an initial token position? This is the least attractive option right?

As off Axon 4.1, which is to be released soon, you can also leverage the EventProcessingConfigurer#registerTrackingEventProcessorConfiguration method to provide a default to be used when building all your Tracking Event Processors.

That sounds good… When do you expect 4.1 :stuck_out_tongue_winking_eye:

Hi Christophe

In the accidental clearing scenario I understand that for some processors you’d like to adjust the Tracking Token position default, yes.
My suggestion to do this is indeed quite cumbersome at this point, especially if you’re used to Spring Boot.
Hence why I added this ticket to open up the initialTrackingToken configuring through a config file, as well as this ticket to change the overall Event Processor defaults through a config file.
The combination of both should make your life even easier than with the feature we added in Axon 4.1 to configure a default through code.

About your question when to expect 4.1: it’s out as off yesterday (13th of March), so please try it out!

Cheers,
Steven

So cool, will do, thank you!