Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
New API for async implicit transactions: runInTransactionAsync
-
Docs Required, Release Notes Required
Description
There is a usability issue for transaction implicit management API.
For async transaction tx.commit must be called after all async ops are enlisted to the transaction. This is a responsibility of a user in case of explicit management.
But, for implicit management, tx.commit must be called automatically. This is not generally not possible for async flows, because by the end of a closure some operations are not yet started.
The example:
runInTransactionAsync(tx ->
{ return opAsync().thenComposeAsync(res -> otherOpAsync()); })
We can fix this by introducing async context for implicit management and require a user to return last completion stage in the chain, like:
<T> CompletableFuture<T> runInTransactionAsync(Function<Transaction, CompletableFuture<T>> clo);
Attachments
Issue Links
- links to