Axon 3 / Mongo configuration + saga cache

Hi,
I’m playing around with all kinds of setups in a spring bootified playground (jpa on various rdbms, mongo, …) with Axon 3.2.2.
My latest configuration is for mongo, and seems to be working:

@Bean
MongoSagaStore mongoSagaStore(MongoTemplate mongoTemplate) {
    return new MongoSagaStore(mongoTemplate);
}

@Bean
MongoEventStorageEngine eventStorageEngine() {
    return new MongoEventStorageEngine(new DBObjectXStreamSerializer(), null, mongoTemplate(), new DocumentPerEventStorageStrategy());
}

@Bean
MongoTemplate mongoTemplate() {
    return new DefaultMongoTemplate(mongo(), "axondb");
}

@Bean
MongoClient mongo() {
    MongoClientURI clientURI = new MongoClientURI("mongodb://xxx:yyy@localhost");
    return new MongoClient(clientURI);
}

@Bean
TokenStore tokenStore() {
    return new MongoTokenStore(mongoTemplate(), new DBObjectXStreamSerializer());
}

However, problems start to occur when adding a caching saga-store:

@Bean
@Primary
SagaStore sagaStore(MongoSagaStore mongoSagaStore, Cache associationsCache, Cache sagaCache) {
    return new CachingSagaStore(mongoSagaStore, associationsCache, sagaCache);
}
@Bean
Cache associationsCache(JCacheCacheManager jCacheCacheManager) {
    javax.cache.Cache cache = jCacheCacheManager.getCacheManager().getCache("saga-associations");
    return new JCacheAdapter(cache);
}

@Bean
Cache sagaCache(JCacheCacheManager jCacheCacheManager) {
    javax.cache.Cache cache = jCacheCacheManager.getCacheManager().getCache("sagas");
    return new JCacheAdapter(cache);

} 

As cache provider, we’ll added ehcache to the classpath:

compile "javax.cache:cache-api:1.1.0"
compile "org.ehcache:ehcache"

Since ehcache loves Serializable, it complains about MongoTrackingToken:

Caused by: java.io.NotSerializableException: org.axonframework.mongo.eventsourcing.eventstore.MongoTrackingToken

Anyone else having trouble with this combination? An easy workaround in mind? I do find it strange that somehow the tracking token is persisted with the saga (and cached accordingly)? With a JPA config, I believe a GapAwareTrackingToken is (auto)configured, which is Serializable. Anything I might have overlooked?

Thanks!

I should mention I’m using a TrackingProcessor for the saga(s), with a simple configuration

@Bean
public org.axonframework.config.SagaConfiguration fooSagaConfiguration() {
    return org.axonframework.config.SagaConfiguration.trackingSagaManager(FooSaga.class)
            .configureTrackingProcessor(c -> TrackingEventProcessorConfiguration.forSingleThreadedProcessing());
}

… and my saga is referring to the spring bean

Hi,

I don’t think you’re missing anything. The MongoTrackingToken should actually have to implement Serializable. I have created an issue (https://github.com/AxonFramework/AxonFramework/issues/685) to track it.

Cheers,

Allard