I can see that there are three options for persisting sagas, either InMemorySagaRepository, JpaSagaRepository or MongoSagaRepository. Since I’ve chosen to persist the events in a MongoDB, I also assume it would be best to store the sagas in the same DB (less to configure, less to maintain etc…). I’ve searched various examples on how to setup the Spring configuration for a MongoSagaRepository, but I’m unable to complete it:(
I paste what I’ve got so far, and hope someone can help me out with the rest:
you don’t need to use a TransactionManager at all. Mongo doesn’t support transactions. When using e.g. JPA, you can set Spring’s PlatformTransactionManager there.
Removing the tx manager should solve your problem.
Cheers,
Follow-up question on the Saga: It seems Spring doesn’t inject the CommandGateway for me, since I get a NullPointerException when building my project. I have my setter for the commandgateway like this:
for resources to be injected, you need to specify a “ResourceInjector”. Since you’re using Spring, you’d most likely want to use the SpringResourceInjector. It will use Spring’s injection mechanism to autowire beans.
Unfortunately, there is no axon-mongo namespace support yet. That could automatically take care of all this.