Question

Here consistent request in Mongo I found how to handle consistent request in java code.

DB db...;
db.requestStart();
try {
   db.requestEnsureConnection();

   code....
} finally {
   db.requestDone();
}

Does spring-data cares about it. Or I should do it manually as using plain java driver?

Was it helpful?

Solution

In spring data to execute with in same connection, you should use mongoTemplate.executeInSession(DbCallback action). Please take a look at the Spring documentation Section 5.1.1 about Execution Callback.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top