1 Reply Latest reply on Jun 22, 2006 5:03 AM by Martinus Martin

    Managing Task and Log ???

    Martinus Martin Newbie

      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 ?


      Regards,

      Martin

        • 1. Re: Managing Task and Log ???
          Martinus Martin Newbie

          Update :

          The case where the log sequence is out of order only happens if I cancel the task, but if I remove the task, the log is ok.

          Now after playing around for a while with canceling and removing task instances, I just found something that I really don't understand.

          Base on the question no 2 that I've posted before. Removing the unfinished task instances will indeed trigger signaling on the task node causing it to move to state c. But if I replace the state c with another task node like this :

           "<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>" +
           " <task-node name='c' >" +
           " <task name='watch movie amadeus 2'>" +
           " <assignment class='test.AssignToJack'/>" +
           " </task>" +
           " <transition to='end'>" +
           " </task-node>" +
           " <end-state name='end' />" +
          
           "</process-definition>"
          



          Now, If I just execute the process definition above (all the way from start state to end state) using the same jbpmContext object, then everything is ok. But if i do this :

          Execute the process from start state until the token enter task node c (where the task ''watch movie amadeus 2'' is assigned to Jack) using the same jbpmContext object.

          Create a new jbpmContext and continue the process by finishing the task ''watch movie amadeus 2'' for jack.

          All of the sudden all the task that has been removed at task node c appear again here as unfinished task instances, thus the token will stay at this node because of it

          Like I said before, this 'removed task instances appear out of nowhere on task node c' only happens if I create a new jbpmContext object. It won't happen if I keep continue the process using the same jbpmContext that I use for finishing task instances on task node t (where the task instances removing happens), it will just simply move the token to end node and finish the process which is the correct thing.

          I really hope somebody could clarify this.....please help.


          Thx and Regards,

          Martin