I’m using quite often the mechanism of asyncBefore and asyncAfter: they allow to configure “pointcut”, so when an execution reaches them, control is returned to the client thread and a background job thread is set to continue with the execution.
This mechanism implies a transaction to commit before this point and a new transaction to start when de job thread continues the execution.
What would be really useful to our application is to define some “pointcut” where the transactions were commited and new transaction started but without returning control to the client thread until next waiting task is reached (userTask/timerEvent/receiveTask/etc…).
Is this possible in camunda?
This should happen when all transactions commit correctly. If a transaction issues a rollback, then the execution could be put in a state where an async continuation deals with it from the point the last transition correctly commited.
THE USE CASE
Consider the following model snippet:
Task1 and Task2 have the same assignee.
When Task1 is completed, our system offers Task2 to the user so he can complete it.
This can be done because Task2 is active when thread control is returned after Task1 completion and Automatic 1 and 2 have executed without exception.
We would like to set asyncAfter=true in automatic1 in order to avoid Automatic1 task to be retried when it have been succesful bu Automatic2 failed.
When we set asyncAfter=true, control is returned to the thread just after Automatic1 so Task2 is not yet available and cannot be offered to the user.