3 Replies Latest reply on Sep 17, 2009 3:44 PM by Joram Barrez

    problem with forks, nodes (abnormally) keep active.

    Paul Wang Newbie

      Hi all, I've got a rather complex workflow which involves several forks in hierarchy. You can take the code for reference.

      The problem is when signaling the state "B.1.1", it's supposed to end this state and enter the next state "B.1.1.1"; but what really happens is "B.1.1.1" is activated and at the same time "B.1.1" still remains active.

      This odd thing happen to "B.1.2" as well; and they keep active so the whole workflow can't finish.

      I've tested on both jbpm4.0 and 4.1 and found no luck.

      Any suggestions?

      <?xml version="1.0" encoding="UTF-8"?>
      
      <process name="test_fork" xmlns="http://jbpm.org/4.0/jpdl">
      
       <start g="222,17,92,52">
       <transition g="-31,-22" name="to A" to="A"/>
       </start>
      
       <end g="172,848,48,48" name="end"/>
       <state g="211,100,92,52" name="A">
       <transition g="-31,-22" name="to B" to="B"/>
       </state>
       <state g="211,184,92,52" name="B">
       <transition g="-56,-22" name="to fork1" to="fork1"/>
       </state>
       <fork g="233,268,48,48" name="fork1">
       <transition g="-43,-22" name="to B.1" to="B.1"/>
       <transition name="to B.2" to="B.2" g="-43,-22"/>
       </fork>
       <state g="149,348,92,52" name="B.1">
       <transition g="-56,-22" name="to fork2" to="fork2"/>
       </state>
       <state g="273,348,92,52" name="B.2">
       <transition name="to B.2.1" to="B.2.1" g="-55,-22"/>
       </state>
       <fork g="140,432,92,52" name="fork2">
       <transition g="-55,-22" name="to B.1.1" to="B.1.1"/>
       <transition g="-55,-22" name="to B.1.2" to="B.1.2"/>
       </fork>
       <state g="16,516,92,52" name="B.1.1">
       <transition name="to B.1.1.1" to="B.1.1.1" g="-67,-22"/>
       </state>
       <state g="140,516,92,52" name="B.1.2">
       <transition g="-56,-22" name="to fork3" to="fork3"/>
       </state>
       <fork g="140,600,92,52" name="fork3">
       <transition g="-67,-22" name="to B.1.2.1" to="B.1.2.1"/>
       <transition g="-67,-22" name="to B.1.2.2" to="B.1.2.2"/>
       </fork>
       <state g="89,684,92,52" name="B.1.2.1">
       <transition g="-54,-22" name="to join1" to="join1"/>
       </state>
       <state g="213,684,92,52" name="B.1.2.2">
       <transition g="-54,-22" name="to join1" to="join1"/>
       </state>
       <join g="172,768,48,48" name="join1">
       <transition g="-46,-22" name="to end" to="end"/>
       </join>
       <state g="16,600,92,52" name="B.1.1.1">
       <transition g="90,771:-54,-22" name="to join1" to="join1"/>
       </state>
       <state g="279,432,92,52" name="B.2.1">
       <transition name="to B.2.1.1" to="B.2.1.1" g="-67,-22"/>
       </state>
       <state g="285,516,92,52" name="B.2.1.1">
       <transition g="354,801:-54,-22" name="to join1" to="join1"/>
       </state>
      
      </process>
      [img][/img]

        • 1. Re: problem with forks, nodes (abnormally) keep active.
          Paul Wang Newbie

          I've made an all-in-one unit test to demo this problem.

          The basic idea behind is during the execution of one process instance, each node shall be active before being signaled and inactive after. The code will print out all remaining active activities.

          But after signaling B.1.1, the resulting output is

          After signaling B.1.1, actives are [B.1.1, B.1.2, B.1.1.1, B.2]


          which is clearly not desirable, and the program broke afterwards.

          package org.jbpm.examples.concurrency.graphbased;
          import java.util.ArrayList;
          import java.util.List;
          import org.jbpm.api.Execution;
          import org.jbpm.api.ProcessInstance;
          import org.jbpm.test.JbpmTestCase;
          
          public class ForkTest extends JbpmTestCase {
           String deployID = null;
           private String processDefinitionKey = "TestFork";
          
           private String getJPDL(){
           String jpdl = String.format(
           "<process name='%s' xmlns='http://jbpm.org/4.0/jpdl'>"
           +""
           +"<start g='211,16,92,52'>"
           +"<transition name='to A' to='A' g='-31,-22'/>"
           +"</start>"
           +""
           +"<end g='172,848,48,48' name='end'/>"
           +"<state name='A' g='211,100,92,52'>"
           +"<transition name='to B' to='B' g='-31,-22'/>"
           +"</state>"
           +"<state name='B' g='211,184,92,52'>"
           +"<transition name='to fork1' to='fork1' g='-56,-22'/>"
           +"</state>"
           +"<fork name='fork1' g='233,268,48,48'>"
           +"<transition name='to B.1' to='B.1' g='-43,-22'/>"
           +"<transition name='to B.2' to='B.2' g='-43,-22'/>"
           +"</fork>"
           +"<state name='B.1' g='149,348,92,52'>"
           +"<transition name='to fork2' to='fork2' g='-56,-22'/>"
           +"</state>"
           +"<state name='B.2' g='273,348,92,52'>"
           +"<transition name='to B.2.1' to='B.2.1' g='-63,-22'/>"
           +"</state>"
           +"<fork name='fork2' g='140,432,92,52'>"
           +"<transition name='to B.1.1' to='B.1.1' g='-55,-22'/>"
           +"<transition name='to B.1.2' to='B.1.2' g='-55,-22'/>"
           +"</fork>"
           +"<state name='B.1.1' g='16,516,92,52'>"
           +"<transition name='to B.1.1.1' to='B.1.1.1' g='-63,-22'/>"
           +"</state>"
           +"<state name='B.1.2' g='140,516,92,52'>"
           +"<transition name='to fork3' to='fork3' g='-56,-22'/>"
           +"</state>"
           +"<fork name='fork3' g='140,600,92,52'>"
           +"<transition name='to B.1.2.1' to='B.1.2.1' g='-67,-22'/>"
           +"<transition name='to B.1.2.2' to='B.1.2.2' g='-67,-22'/>"
           +"</fork>"
           +"<state name='B.1.2.1' g='89,684,92,52'>"
           +"<transition name='to join1' to='join1' g='-54,-22'/>"
           +"</state>"
           +"<state name='B.1.2.2' g='213,684,92,52'>"
           +"<transition name='to join1' to='join1' g='-54,-22'/>"
           +"</state>"
           +"<join name='join1' g='172,768,48,48'>"
           +"<transition name='to end' to='end' g='-46,-22'/>"
           +"</join>"
           +"<state name='B.1.1.1' g='16,600,92,52'>"
           +"<transition name='to join1' to='join1' g='90,771:-54,-22'/>"
           +"</state>"
           +"<state name='B.2.1' g='279,432,92,52'>"
           +"<transition name='to B.2.1.1' to='B.2.1.1' g='-63,-22'/>"
           +"</state>"
           +"<state name='B.2.1.1' g='285,516,92,52'>"
           +"<transition name='to join1' to='join1' g='354,801:-54,-22'/>"
           +"</state>"
           +""
           +"</process>", processDefinitionKey);
          
           return jpdl;
           }
          
           protected void setUp() throws Exception {
           super.setUp();
           String jpdl = getJPDL();
           deployID = repositoryService.createDeployment().addResourceFromString("test_fork.jpdl.xml", jpdl).deploy();
           }
          
           protected void tearDown() throws Exception {
           repositoryService.deleteDeployment(deployID);
          
           super.tearDown();
           }
          
           public void testConcurrencyGraphBased() {
           ProcessInstance processInstance = executionService.startProcessInstanceByKey(processDefinitionKey);
           List<String> path = new ArrayList<String>();
           path.add("A");
           path.add("B");
           path.add("B.1");
           path.add("B.1.1");
           path.add("B.1.1.1");
           path.add("B.1.2");
           path.add("B.1.2.1");
           path.add("B.1.2.2");
          
           for (String activityName : path){
           assertNotNull(processInstance.findActiveExecutionIn(activityName));
           Execution execution = processInstance.findActiveExecutionIn(activityName);
           processInstance = executionService.signalExecutionById(execution.getId());
           System.out.println(String.format("After signaling %s, actives are %s", activityName, processInstance.findActiveActivityNames()));
           assertNull(processInstance.findActiveExecutionIn(activityName));
           }
           }
          }


          • 2. Re: problem with forks, nodes (abnormally) keep active.
            Ronald van Kuijk Master

            Thanks for the complete all in one unittest (hear, hear).

            This might be related to https://jira.jboss.org/jira/browse/JBPM-2528 and maybe https://jira.jboss.org/jira/browse/JBPM-2516

            I'll point to this post in the last issue

            • 3. Re: problem with forks, nodes (abnormally) keep active.
              Joram Barrez Master

              Paul, couldn't the problem be related to the fact you have 3 forks, but only 2 joins (ie not nested correctly)?