2 Replies Latest reply on Dec 23, 2008 7:43 AM by Romain Lamarche

    Cancelling dynamically created tasks

    Maciej Lizewski Newbie

      Have such case:

      in one task-node I create few tasks for different actors (every one of them has to accept processed document). This is done in node-enter event when entering this task-node.

      I would like to cancel all pending tasks in this node when first of those actors rejects (takes "reject" transition). How to do this?

      When I write handler for task-end event that iterates through pending tasks and calls "cancel" method I get exception that the token is locked...

      simplified example of this proces:

      <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="Proces">
      
      <start-state name="start">
       <transition to="accept" name="send"/>
      </start-state>
      
      <task-node name="accept" create-tasks="false" signal="last-wait">
       <event type="node-enter">
       <action name="create tasks" class="xxx.CreateAcceptTasks">
       <actorIds>actor1,actor2,actor3,actor4</actorIds>
       </action>
       </event>
       <event type="task-end">
       <action name="is positive?" class="xxx.AcceptTaskEnd">
       </action>
       </event>
       <task name="accept"></task>
       <transition to="accepted" name="accept"></transition>
       <transition to="rejected" name="reject"></transition>
      </task-node>
      
      ...
      
      </process-definition>
      


      xxx.CreateAcceptTasks

      just creates TaskInstances of "accept" Task and assignes them to actors provided in param.

      xxx.AcceptTaskEnd

      ???
      when I tried to fetch pending tasks with executionContext.getTaskMgmtInstance().getTaskInstances()

      and then call "cancel" on every pending tasks (that is not equal to current task of course) - I get "Token locked" exception...

      Any help would be appreciate...