The MongoDB documentation (https://www.mongodb.com/docs/manual/reference/change-events/) specifies that for a change event, the transaction associated with that event can be uniquely identified by the lsid
and txnNumber
fields in the ChangeStream document. Say if a user executes a transaction containing 10 inserts, all the 10 ChangeStream documents will have the same lsid
and txnNumber
.
The problem during change data capture using ChangeStream is that I'm not able to determine whether the transaction has ended or not unless and otherwise the next transaction comes in (different txnNumber
) or a normal database operation (lsid
and txnNumber
are null
using the Java driver) is performed. So, is there any way to determine if the current transaction has ended or not from the ChangeStream without needing another consecutive operation?