Hello, trademak. Thank you for your response.
It turned out, that I can't just use TaskService, because while in TaskListener (create/assignment) the task is not yet persisted and it can not be found by TaskService.
I did this:
<code> taskService.complete(delegateTask.getId(), variables);</code>
And it threw exception.
By the way, I have tried other variants (which did not work for me):
- signal execution by runtimeService
<code> DelegateExecution execution = delegateTask.getExecution();
runtimeService.signal(execution.getId());</code>
- listen for the transaction commit and do my work post-commit
<code>Context.getCommandContext()
.getTransactionContext()
.addTransactionListener(TransactionState.COMMITTED, new TransactionListener() {
public void execute(CommandContext commandContext) {
taskService.complete(taskId, variables);
}
});</code>
It seemed to execute smoothly on Activiti side, but failed to commit on external transaction (Alfresco transaction), where I caught exception, that a node was changed concurrently in several transactions (other listeners do this job).
- listen for the external (Alfresco) transaction commit and do my work post-commit
I caught the same exception as previous.
Maybe it is more correct to post this question on Alfresco forums?
However, I suppose, that Alfresco-like configuration is not the unique one: other configurations also can use external transactions and face similar problems.