Class MongoTransactionManager

All Implemented Interfaces:
Serializable, InitializingBean, ConfigurableTransactionManager, PlatformTransactionManager, ResourceTransactionManager, TransactionManager

public class MongoTransactionManager extends AbstractPlatformTransactionManager implements ResourceTransactionManager, InitializingBean
A PlatformTransactionManager implementation that manages ClientSession based transactions for a single MongoDatabaseFactory.
Binds a ClientSession from the specified MongoDatabaseFactory to the thread.
Readonly transactions operate on a ClientSession and enable causal consistency, and also start, commit or abort a transaction.
Application code is required to retrieve the MongoDatabase via MongoDatabaseUtils.getDatabase(MongoDatabaseFactory) instead of a standard MongoDatabaseFactory.getMongoDatabase() call. Spring classes such as MongoTemplate use this strategy implicitly.
By default failure of a commit operation raises a TransactionSystemException. One may override doCommit(MongoTransactionObject) to implement the Retry Commit Operation behavior as outlined in the MongoDB reference manual.
Since:
2.1
Author:
Christoph Strobl, Mark Paluch
See Also: