Always invokin an In memory token store though configured to enable mongodb token. How to point mongodb event storer

That is curious, @Mohan_S.
I guess you’re hitting a Spring ordering issue, but that’s hard to tell for certain given the current set of information you’ve given.

What you could try to enforce things, is add some Java configuration, like so:

@Bean
public ConfigurerModule mongoTokenStoreConfigurerModule(MongoTokenStore tokenStore) {
    return configurer -> configurer.eventProcessing().registerTokenStore(config -> tokenStore);
}

Having that ConfigurerModule in your Application Context should ensure that the default TokenStore throughout your Axon Framework application is the MongoTokenStore.

Please let me know if this works!

The token store is enabled by default. However the correct property is axon.mongo.tokenstore.enabled. Also you need to have the Mongo extension starter available https://mvnrepository.com/artifact/org.axonframework.extensions.mongo/axon-mongo-spring-boot-starter.

1 Like

Unable to start application due to following error.

Parameter 0 of method mongoTokenStoreConfigurerModule in com.saturn.estore.ProductService.Config.AxonConfig required a bean of type ‘org.axonframework.extensions.mongo.eventsourcing.tokenstore.MongoTokenStore’ that could not be found.

Could you please kindly help us.

in fact you don’t have to create any beans
just add mongo boot-starter dependency

implementation(“org.axonframework.extensions.mongo:axon-mongo-spring-boot-starter:$axonExtVersion”)

in application.yml add those properties

{A4DB10F3-B28C-4CC2-BD8E-6EF05BB056DA}

mongo db must be started in replicaSet mode

1 Like

Still unable to start application despite using axon mongodb dependency and ideal yml configuration. It throws the error below:

Caused by: com.mongodb.MongoCommandException: Command failed with error 72 (InvalidOptions): ‘writeConcern is not allowed within a multi-statement transaction’ on server



Note: I am using AxonServer together with MongoDB Atlas Cloud

Hi All,

I am able to resolve the issue by compiling the database with axon’s MongoTemplate then building with axon’s MongoTokenStore. By doing this, Spring boot application has started to use mongodb’s tokenstore instead of in memory tokenstore provided default by axon.

@Bean
public TokenStore tokenStore(MongoClient mongoClient, Serializer serializer) {
MongoTemplate mongoTemplate = DefaultMongoTemplate.builder()
.mongoDatabase(mongoClient, “databasehere”)
.build();
return MongoTokenStore.builder()
.mongoTemplate(mongoTemplate)
.serializer(serializer)
.build();
}

Note: I leveraged axon mongo dependency to resolve this issue.

Thank you for each and everyone to resolve this issue, you people are so great and helpful.