Axon 4.1 with axon server: JdbcTokenStore is not used

Cannot switch to using a JdbcTokenStore. Axon keeps running an InMemoryTokenstore instead. According to documentation, the presence of a DataSource should cause axon to switch to a JdbcTokenStore. It is not…

Following configuration:- axon server 4.1 on a remote host

  • a mariadb database on a remote host with following schema:

MariaDB [axontokenstore]> describe TokenEntry;

This is what is states in the documentation in the Axon 4.1 reference guide for Spring Boot autoconfiguration

I tried adding the following configuration:

@Configuration
public class AxonConfig {

    @Autowired
    public void configureTokenStore(Configurer configurer, TokenStore tokenStore) {
        configurer.eventProcessing().registerTokenStore(c -> tokenStore);
    }
}

tokenStore is indeed the JdbcTokenStore.
however, this did not work as there were no tokens intitialized in the JdbcTokenStore. So it tries to fetch a token for update (the select for update works, but the result is empty, and then the update of course don’t work)

With my added configuration, the JdbcTokenStore does initialize correctly for the segments, given that the database table structure is correct, and this was not the case.

This is the correct structure:

MariaDB [axontokenstore]> describe TokenEntry;

Hi Stijn,

looking at the code, I don’t see any reason why the JDBC component should not be automatically picked up.
If you run you application without an explicit TokenStore configuration and with the “–debug” flag, it should give you an overview of which beans have been accepted and rejected for auto configuration. It should indicate why the “tokenStore” in JdbcAutoConfiguration has not been included.

Hope this helps.

Hi Allard,

Sorry, it has been a while I looked at this issue.

Meanwhile, I have switched from axon 4.1 to axon 4.1.1 (no change in behaviour)

When running --debug, I see the following:

JdbcAutoConfiguration#tokenStore matched:

  • @ConditionalOnMissingBean (types: org.axonframework.eventhandling.tokenstore.TokenStore; SearchStrategy: all) did not find any beans (OnBeanCondition)

So this is where the JdbcTokenStore gets instantiated.
Then, AxonAutoconfiguration must be processed AFTER JdbcAutoConfiguration, otherwise, it might not detect the JdbcTokenStore.

In the Axon code, I see:

@AutoConfigureAfter(EventProcessingAutoConfiguration.class)
public class AxonAutoConfiguration implements BeanClassLoaderAware { 

And in EventProcessingAutoConfiguration, I see:

@Configuration
@AutoConfigureAfter(name = {
        "org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration",
        "org.axonframework.springboot.autoconfig.JpaAutoConfiguration",
        "org.axonframework.springboot.autoconfig.JpaEventStoreAutoConfiguration",
        "org.axonframework.springboot.autoconfig.ObjectMapperAutoConfiguration"
})
public class EventProcessingAutoConfiguration {

Why is JpaAutoConfiguration included in “AutoConfigureAfter”, but JdbcAutoConfiguration not? Perhaps this is why the JdbcTokenStore (created in JdbcAutoConfiguration) is not picked up in time?

Hi Stijn,

this is indeed an issue in the JdbcAutoConfiguration set up. I’ve created an issue in Github (https://github.com/AxonFramework/AxonFramework/issues/1077) it and planned it to be part of 4.1.2.

Kind regards,

thanx!

Hello,

I’m facing the same issue.
Could you tell us when the 4.1.2 will be delivered ?

Hi Lionel,

Thanks for your interest in the 4.1.2 release of Axon Framework.
The 4.1.2 has is currently in the closed state, but I however conclude it’s not actually published yet.

I’ve been on vacation for some time, so I need to do some investigation first prior to resolving this myself to ensure everything is in as intended.

Regardless, 4.1.2 should be out there soon, I’d say at least next week.

Sorry for the inconvenience thus far Lionel, hope this clarifies things.

Cheers,
Steven