4 Replies Latest reply on Dec 2, 2009 2:52 PM by saraswati.santanu

    How to suspend Join Execution

      Hi, I'm using JBPM4 with SQLServer.

      I've created a process XML such that it creates 4 parallel Tasks with Fork.
      These 4 tasks joins on completion(Approval) to initiate another new Task(single).

      My requirement is:
      If any task requests a rework, rest of all active tasks should gets terminated/ended. But when I'm trying to end any execution (by retrieving all tasks) I'm getting no session found.
      How to end these Tasks/executions ?? or End Join Execution ??

      Thanks in Advance.

        • 1. Re: How to suspend Join Execution

          Hello pradeep.gulla,

          Can you give us more details ? A good start to report problems is to read the following thread:
          http://www.jboss.org/index.html?module=bb&op=viewtopic&t=158610

          And to post the maximum of the requested points.

          Regard,
          David

          • 2. Re: How to suspend Join Execution
            saraswati.santanu

            Pradeep,
            your problem is not very clear to me. It will be helpful if you can provide some code that can get the exception.

            However, whatever I understood, an approach may be to add a start event listener on the join node and delete the tasks you do not need when there is a request for rework. A sample code for the start event listener of the join node may be like this:

             public void notify(EventListenerExecution execution) throws Exception {
             Task task = //find the task you need to invalidate
             //ugly casting. Is there a better way
             ((TaskImpl)task).setExecution((Execution)null);
             ((TaskImpl)task).setExecutionDbid(null);
             //now delete the task
             taskService.deleteTask(task.getId());
             }
            


            You can always check and see if there is a better way to delete an existing task.

            • 3. Re: How to suspend Join Execution

              Hi Santanu,


              The code: taskService.deleteTask(task.getId()); throwing exception

              tasks related to an execution must be completed. they cannot just be deleted


              My Implementation:

              Process XML:

              <process name="test_workflow" version="4" xmlns="http://jbpm.org/4.0/jpdl">
              <start g="15,390,80,40">
               <transition to="validate approval sequence"/>
              </start>
              <decision name="validate approval sequence" expr="${approvalSequence}">
               <transition name="parallel" to="assign parallel tasks"/>
               <transition name="seqential" to="first sequential Task"/>
              </decision>
              <fork name="assign parallel tasks">
               <transition to="first parallel task"/>
               <transition to="second parallel task"/>
               <transition to="third parallel task"/>
              </fork>
              <task name="first parallel task">
               <transition to="wait"/>
              <transition name="rework" to="disable all active tasks"/>
              </task>
              <task name="second parallel task">
               <transition to="wait"/>
              <transition name="rework" to="disable all active tasks"/>
              </task>
              <task name="third parallel task">
               <transition to="wait"/>
              <transition name="rework" to="disable all active tasks"/>
              </task>
              <join name="wait">
               <transition to="first sequential task"/>
              </join>
              <task name="first sequential Task">
               <transition name="approve" to="second sequential Task"/>
              </task>
              <task name="second sequential Task">
               <transition name="approve" to="stop"/>
              </task>
              <!-- Should disable all active parallel tasks -->
              <custom name="disable all active tasks" class="ReworkHandler">
               <transition to="rework task"/>
              </custom>
              <task name="rework task">
               <transition name="restart" to="validate approval sequence"/>
              </task>
              <end name="stop"/>
              


              Handler class:
              public class ReworkHandler implements ExternalActivityBehaviour{
               public void execute(ActivityExecution execution) {
               ..................
               taskService.deleteTask(task.getId());
               }
              }


              Am I' missing anything ??
              .

              • 4. Re: How to suspend Join Execution
                saraswati.santanu

                Did you do these two steps before deleting?

                 ((TaskImpl)task).setExecution((Execution)null);
                 ((TaskImpl)task).setExecutionDbid(null);
                


                The task should not be associated with any execution if you want to delete that. So before deleting set the execution as null, so that the task is kind of orphaned.

                Your flow might have some problem. You are jumping out of the fork-join without completing the join activity. This might create some confusion. I believe this can be done in a cleaner way.