I have an Activiti flow that has a User Task section, that looks like this:
The basic idea is that the "Wait for Notification" user task, waits for a response from special Queue. But actualy a specific code just compets the task:
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("KEY", variable);
String assignee = variable.getAssignee();
processService.completeTask(assignee, variables);
So my problem is that the service responsible for this code can receive several responses form that queue. Which is the kind of behavior I want (the Queue, can return something like Message_Processed and after a few milliseconds return Message_Send). But when the second response comes the Activiti Engine throws an Exception (see cause), and the whole flow dies.
Caused by: org.activiti.engine.ActivitiOptimisticLockingException: Task[id=3867, name=Wait for Notification] was updated by another transaction concurrently
So what I'm looking for: Is there a way to make a task, somehow that it will take and swallow all responses not throwing an Exception.