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.
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
mongo db must be started in replicaSet mode
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.