Consider this example :
"<process-definition>" + " <start-state name='a'>" + " <transition to='b' />" + " </start-state>" + " <state name='b'>" + " <transition to='t' />" + " </state>" + " <task-node name='t' create-tasks='false'>" + " <event type='node-enter'>" + " <action class='test.CreateTasks' />" + " </event>" + " <task name='watch movie amadeus'>" + " <event type='task-end'>" + " <action class='test.CheckTasks' />" + " </event>" + " </task>" + " <transition to='c' />" + " </task-node>" + " <state name='c' />" + "</process-definition>"
In the action of node-enter event, 10 task instances will be created and assigned to 10 different actors, but only 3 actors need to finish the tasks. So my questions are :
1. Since the program need to check whether 3 task instances already finished or not, I register an action class on 'task-end' event to do the checking. To keep the track of how may task instances have been finished I use a process variable, so every time a task instance is finished, the test.CheckTasks class will get the variable, increase the value and return it. Is this the correct way ? Will this work in an environment where concurrent access to the process can happen ? if not then what is the best way to do this ?
2. In this case, everytime 3 task instances has been finished, the process needs to continue to the next stage (in this case it should be to state c) automatically. So in order to fulfill this, in class test.CheckTasks all other unfinished task instances will be removed and as the result the process does continue to state c, but if I check the log I can see that the process sequences is out of order. The TaskEndLog happens after the token reaches state c and not before it. If I replace the state c with end node it will become more confusing because the log will indicate that the ProcessInstanceEndLog happens before TaskEndLog. How could this be ? Did I miss something here ?