session.abortTransaction does not rollback elements inserted after startTransaction

Hi @st-h,

Nearly there - you just need to add the session in the insertOne call, so that the session is used and then it should work as expected. eg:

collection.insertOne(clientSession, new Document("_id", 1).append("msg", "test"));

Regarding documentation, I agree and this is something we as a team are looking at improving in the future as well as potentially a friendlier API. The main issue is using raw Publishers would make the documentation extremely verbose and confusing. However, I can see using a library like Reactor or RxJava should really reduce the complexity of the code and that may be the way forward.

All the best,

Ross

1 Like