Reputation: 630
Two user tasks (task A and B) are created in parallel, and when one task is completed need to cancel the other vice versa. This can be done with the use of a task listener (event on complete). However the issue is if both tasks are completed at the same time how to handle it?
Upvotes: 0
Views: 585
Reputation: 169
I recommend that you create a userTask with multiple instances
. It can create multiple usertasks at the same time and set different conditions to end the multiple instances.
<userTask id="userTask1" name="Activiti is awesome!" activiti:assignee="${user}">
<multiInstanceLoopCharacteristics isSequential="false" activiti:collection="${userList}" activiti:elementVariable="user">
<completionCondition>${nrOfCompletedInstances == nrOfInstances}</completionCondition>
</multiInstanceLoopCharacteristics>
</userTask>
More information can be found at activiti User Guide#Multi-instance
Hope that can solve your problem!
Upvotes: 0
Reputation: 4143
Have you tried that out? Competing a task is a transactional operation, that means that if both tasks are completed at the same time only one transaction will “win” and the other will be rolled-back pushing the second transaction to be retried. In general that should work if you have that retrying mechanism
Upvotes: 2