cancel
Showing results for 
Search instead for 
Did you mean: 

Reassigning & Task Complete race problem

shiva_arunachal
Champ in-the-making
Champ in-the-making
i was doing some study on how to make task reassignment and completion fail proof. i tested explorer in below scenario and it failed.
i opened two browers. opened same user task on both browsers. Now did task "reassign" from one browser. and after that task "complete" from another browser. since i reassigned task before clicking on "complete" i expected some kind of error. but no error came. Now as per task service documentation,
void complete(String taskId); 
throws only two exceptions…:

/*@throws ActivitiObjectNotFoundException when no task exists with the given id.
   * @throws ActivitiException when this task is {@link DelegationState#PENDING} delegation.
   */
  void complete(String taskId);

  Now task exists with the given id so no exception was thrown.
My question 1: how can i prevent same situation from appearing in my own application? I have a supervisor who can reassign tasks huge number of tasks.
But if a user has already opened a task, and is working on it, i dont want supervisor to do a reassign on it. (OR) if a supervisor reassigns a task, the origin user should not be able to complete  the task.
question 2: How can i achieve this?
10 REPLIES 10

jbarrez
Star Contributor
Star Contributor
Hence why i said in the beginning

'you should add a check before doing the complete call.'

You need to make that one transaction in your application. Synchronized is never a good idea, cause it doesn't work in a clustered environment.