I have posted this question on stackoverflow, however haven’t received any good answers so far: https://stackoverflow.com/questions/62810656/generic-transaction-error-handling-with-rxjava-mongodb
Basically, I find myself pretty much handling all transaction in the same way:
.flatMap(someRepository.commitTransaction(sessionReference)) // commit .doOnError(throwable -> sessionReference.get().abortTransaction()) // rollback .doFinally(() -> sessionReference.get().close())
as copying all that code every time isn’t such a nice idea, I was looking for a generic way to handle this.
Additionally a user suggested that I should be using the api described here: https://docs.mongodb.com/manual/core/transactions/ as it would provide additional retry logic, handle write conflicts etc.
I haven’t found anything in the docs, that there would be such a difference between those apis. Additionally there are no async/reactive examples, and I couldn’t find this api in the reactive driver. Could someone please clarify, if these claims are true? If so, what does one need to implement to have the reactive driver deal with those situations in a similar way?