[JAVA-3539] Implement convenient reactive API for Transactions Created: 05/Nov/18  Updated: 19/Sep/23

Status: Backlog
Project: Java Driver
Component/s: Reactive Streams, Scala
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Rathi Gnanasekaran Assignee: Unassigned
Resolution: Unresolved Votes: 5
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to JAVA-4527 Reactive streams clientSession.startT... Closed
is related to DRIVERS-556 Implement Convenient API for Transact... Closed
Epic Link: Async Txn API
Case:

 Description   

See DRIVERS-556 for details.



 Comments   
Comment by Debabrata Patnaik [ 19/Sep/23 ]

https://quarkus.io/guides/mongodb-panache#reactive-transactions

 

Reactive transactions

MongoDB offers ACID transactions since version 4.0.
To use them with reactive entities or repositories you need to use {{}}

io.quarkus.mongodb.panache.common.reactive.Panache.withTransaction()

{{}}

{{}}

@POST
public Uni<Response> addPerson(ReactiveTransactionPerson person) {
    return Panache.withTransaction(() -> person.persist().map(v -> {
        //the ID is populated before sending it to the database
        String id = person.id.toString();
        return Response.created(URI.create("/reactive-transaction/" + id)).build();
    }));
} 

{}{}
In MongoDB, a transaction is only possible on a replicaset, luckily our Dev Services for MongoDB setups a single node replicaset so it is compatible with transactions.

  Reactive transaction support inside MongoDB with Panache is still experimental.
Comment by Ashni Mehta [ 15/Sep/23 ]

There's no traction as yet, as it's not clear what direction to go.  So long as the reactive driver API is solely based on the Reactive Streams API, there is not much we can do, as there is no larger context that we can use to orchestrate transactional behavior.  Contrast this, for example, with Spring Data Reactive Transactions, which relies on all the machinery available via Project Reactor.

We are open to considering this in the future, but as it stands currently, the community desire for this feature isn't quite where it would need to be to warrant the substantial lift this would require.

Have you explored any workarounds, like Spring Data MongoDB or the forthcoming Loom? Or is your preference for the Java driver to provide a standalone reactive transaction manager that is based on something like Project Reactor?

Comment by Debabrata Patnaik [ 18/Jun/23 ]

Its been 5 years and still in backlog. Any traction on this.

Comment by Stefan Huber [ 13/Oct/20 ]

@Esha Bhargava 

I think JAVA-3067 targets only the sync java driver, whereas this issue targets the reactive streams / async driver.

Comment by Esha Bhargava [ 15/Apr/20 ]

dup of JAVA-3067

Generated at Thu Feb 08 08:59:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.