Hands on MongoDB 4.0 transactions with Spring Data
With MongoDB 4.0, ACID transactions have arrived in the Document
store, enforcing all-or-nothing execution and maintaining data integrity. So, let’s get straight to it by looking at both the synchronous and the reactive execution models.
At the time of this writing, MongoDB multi-document transactions are supported across a single replica set and feel like the transactions you are probably familiar with from relational databases. Looking at the driver API, one feels immediately at home:
try (ClientSession session = client.startSession()) {
session.startTransaction();
try…