-
Notifications
You must be signed in to change notification settings - Fork 1.2k
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add DSLContext.transactionAsync(TransactionRunnable) and transactionResultAsync(TransactionCallable) #4435
Comments
This is perhaps related to #4371. In previous versions, we had implemented "asynchronous" fetch operations, although the right choice of API is not obvious to accommodate all possible needs. In the case of transactions, the semantics of "async" becomes even more delicate as we might need to make assumptions about the |
The only things which holds me back from implementing custom async transaction is |
Thanks for the additional info. We can probably open up |
Unfortunately |
Yes, we're aware of that: #4290. This will be fixed very soon. There's no reason to cache the Connection |
Does it mean nested transactions could potentially use different connections? |
Not with the current |
We'll be looking into this in the context of the upcoming |
I've spent some more time thinking about asynchronicity and possibly even "reactiveness" (flow API). There's no need to wait for |
A naive implementation in @Override
public CompletionStage<Void> transactionAsync(TransactionalRunnable transactional) {
return CompletableFuture.runAsync(() -> transaction(transactional));
}
@Override
public CompletionStage<Void> transactionAsync(Executor executor, TransactionalRunnable transactional) {
return CompletableFuture.runAsync(() -> transaction(transactional), executor);
}
@Override
public <T> CompletionStage<T> transactionResultAsync(TransactionalCallable<T> transactional) {
return CompletableFuture.supplyAsync(() -> transactionResult(transactional));
}
@Override
public <T> CompletionStage<T> transactionResultAsync(Executor executor, TransactionalCallable<T> transactional) {
return CompletableFuture.supplyAsync(() -> transactionResult(transactional), executor);
} This would encapsulate the entire transaction (including translating exceptions to rollback) inside the |
…sactionResultAsync(TransactionCallable)
@jCalamari : Would you mind explaining again your rationale from #4435 (comment) ? What needs to be changed in |
Currently, it is only possible to run a synchronous transaction using DSLContext API. How difficult would it to support asynchronous transactions?
Something like:
Or:
The text was updated successfully, but these errors were encountered: