4 Replies Latest reply on Feb 10, 2006 12:46 PM by koen.aers

    fork & join not working properly

    forjbpm

      Hi!
      I have a process definition like

      
      <?xml version="1.0" encoding="UTF-8"?>
      <process-definition
       xmlns="urn:jbpm.org:jpdl-3.1" name="MyDef">
       <swimlane name="user"></swimlane>
       <start-state name="Step1">
       <task name="Step1" swimlane="user">
       <controller>
       <variable name="var1"></variable>
       <variable name="var2"></variable>
       <variable name="var3"></variable>
       </controller>
       </task>
       <transition name="" to="DocFork"></transition>
       </start-state>
       <fork name="DocFork">
       <transition name="Step21" to="Step21">
       </transition>
       <transition name="Step22" to="Step22">
       </transition>
       </fork>
       <task-node name="Step21">
       <task name="Step21" swimlane="user">
       <controller>
       <variable name="var1"></variable>
       <variable name="var2"></variable>
       <variable name="var3"></variable>
       </controller>
       </task>
       <event type="node-enter">
       <action name="action1" class="com.MyDef.step21.class"></action>
       </event>
       <transition name="" to="DocJoin">
       </transition>
       </task-node>
       <task-node name="Step22">
       <task name="Step22" swimlane="user">
       <controller>
       <variable name="var1"></variable>
       <variable name="var2"></variable>
       <variable name="var3"></variable>
       </controller></task>
       <event type="node-enter">
       <action name="action1" class ="com.MyDef.step22.class"></action>
       </event>
       <transition name="" to="DocJoin">
       </transition>
       </task-node>
       <join name="DocJoin">
       <transition name="" to="step3"></transition>
       </join>
       <task-node name="step3">
       <task name="step3" swimlane="user">
       <controller>
       <variable name="var1"></variable>
       <variable name="var2"></variable>
       <variable name="var3"></variable>
       </controller>
      
       </task>
       <transition name="" to="End">
       </transition>
       </task-node>
       <end-state name="End"></end-state>
      </process-definition>
      
      
      


      my com.MyDef.step21 & step 22 action handlers are :
      public void execute(ExecutionContext exeContext) throws Exception {
       // execute external program
       Process p = Runtime.exec("/home/Myprogram.sh");
       // wait for the program to terminate
       p.waitFor();
       // resume the process
       exeContext.leaveNode();
      }



      Interestingly when I start new process execution and when it reaches the fork.
      I get three instances of the same flow.
      one is in step21 state.
      second is in step22 state
      and third is in step 3 state!!!!

      Any comments??
      Do I consider it as a bug or I need to change my process diagram. In reality all these steps represent imoprtant steps in our product.

      Regards and Thanks in advace!




        • 1. Re: fork & join not working properly
          forjbpm

          Hi!
          I just found out that..
          However when I dont assign any swimlane to Step21 & Step 22 and set blocking true. It work perfectly.
          But it may be because as there is no swimlane to those tasks they are not dispalyed??


          <?xml version="1.0" encoding="UTF-8"?>
          <process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="MyDef">
           <swimlane name="user"></swimlane>
           <start-state name="Step1">
           <task name="Step1" swimlane="user">
           <controller> <variable name="var1"></variable>
           <variable name="var2"></variable>
           <variable name="var3"></variable>
          </controller> </task>
          <transition name="" to="DocFork"></transition>
           </start-state>
          <fork name="DocFork">
          <transition name="Step21" to="Step21"> </transition>
          <transition name="Step22" to="Step22"> </transition>
          </fork>
          <task-node name="Step21">
          <task name="Step21" blocking="true">
           <controller> <variable name="var1"></variable>
           <variable name="var2"></variable>
          <variable name="var3"></variable>
          </controller>
          </task>
           <event type="node-enter">
           <action name="action1" class="com.MyDef.step21.class"></action>
           </event>
          <transition name="" to="DocJoin">
           </transition> </task-node>
          <task-node name="Step22">
          <task name="Step22" blocking="true">
           <controller> <variable name="var1"></variable>
          <variable name="var2"></variable>
           <variable name="var3"></variable>
          </controller></task>
          <event type="node-enter">
           <action name="action1" class ="com.MyDef.step22.class"></action>
           </event> <transition name="" to="DocJoin"> </transition> </task-node>
           <join name="DocJoin">
          <transition name="" to="step3"></transition> </join>
           <task-node name="step3"> <task name="step3" swimlane="user">
          <controller> <variable name="var1"></variable>
          <variable name="var2"></variable>
           <variable name="var3"></variable>
           </controller> </task>
          <transition name="" to="End">
          </transition> </task-node> <end-state name="End"></end-state>
          </process-definition>
          
          
          
          
          


          • 2. Re: fork & join not working properly
            koen.aers

            You should *not* try to leave a node from within an actionhandler. If you want to launch a process upon node entry and move out of the node when the process is finished you should use a message driven bean and a message queue.

            Regards,
            Koen

            • 3. Re: fork & join not working properly
              forjbpm

              Hi Koen,

              Is there any specifc reason to do this??
              Please have a look at
              http://www.jboss.com/index.html?module=bb&op=viewtopic&t=76586
              When I can signal a token from outside of the program(message driven beans ) why can't I do it from whithin my action handler?

              Regards,

              • 4. Re: fork & join not working properly
                koen.aers

                The exectute method in the thread you mention is the execute method in a custom node and not the execute method of an action handler.
                Leaving a node should only been done by the node itself (i.e. by the execute method of the node). If you mess with this behaviour outside a node (e.g. in an actionhandler) the execution of the graph will indeed be broken.
                Signalling the token is not the same as leaving a node. Signalling the token is a transactional operation. Leaving the node is a result of signalling the token. So signalling the token from an MDB is not the same as calling the leaveNode method in your action handler. Read the documentation on the Graph Execution Algorithm for more details.

                Regards,
                Koen