Uploaded image for project: 'jBPM'
  1. jBPM
  2. JBPM-3202

Process doesn't end when it reaches End.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Critical Critical
    • jBPM 5.0
    • None
    • None
    • None
    • Hide

      import java.io.Reader;
      import java.io.StringReader;

      import junit.framework.TestCase;

      import org.drools.RuleBase;
      import org.drools.RuleBaseFactory;
      import org.drools.WorkingMemory;
      import org.drools.compiler.PackageBuilder;

      import org.drools.process.instance.ProcessInstance;
      import org.drools.rule.Package;

      public class FlowTest extends TestCase {

      public void testProcess() throws Exception

      { RuleBase ruleBase = readRule(true); WorkingMemory workingMemory = ruleBase.newStatefulSession(); ProcessInstance processInstance = ( ProcessInstance ) workingMemory.startProcess("com.sample.ruleflow"); assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState()); }

      private static RuleBase readRule(boolean independent) throws Exception

      { PackageBuilder builder = new PackageBuilder(); Reader source = new StringReader( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<process xmlns=\"http://drools.org/drools-5.0/process\"\n" + " xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n" + " type=\"RuleFlow\" name=\"ruleflow\" id=\"com.sample.ruleflow\" package-name=\"com.sample\" >\n" + "\n" + " <header>\n" + " <variables>\n" + " <variable name=\"x\" >\n" + " <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n" + " <value></value>\n" + " </variable>\n" + " <variable name=\"m\" >\n" + " <type name=\"org.drools.process.core.datatype.impl.type.IntegerDataType\" />\n" + " <value></value>\n" + " </variable>\n" + " </variables>\n" + " </header>\n" + "\n" + " <nodes>\n" + " <start id=\"1\" name=\"Start\" />\n" + " <end id=\"3\" name=\"End\" terminate=\"false\"/>\n" + " </nodes>\n" + "\n" + " <connections>\n" + " <connection from=\"1\" to=\"3\" />\n" + " </connections>\n" + "\n" + "</process>"); builder.addRuleFlow(source); Package pkg = builder.getPackage(); RuleBase ruleBase = RuleBaseFactory.newRuleBase(); ruleBase.addPackage( pkg ); return ruleBase; }

      }

      Show
      import java.io.Reader; import java.io.StringReader; import junit.framework.TestCase; import org.drools.RuleBase; import org.drools.RuleBaseFactory; import org.drools.WorkingMemory; import org.drools.compiler.PackageBuilder; import org.drools.process.instance.ProcessInstance; import org.drools.rule.Package; public class FlowTest extends TestCase { public void testProcess() throws Exception { RuleBase ruleBase = readRule(true); WorkingMemory workingMemory = ruleBase.newStatefulSession(); ProcessInstance processInstance = ( ProcessInstance ) workingMemory.startProcess("com.sample.ruleflow"); assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState()); } private static RuleBase readRule(boolean independent) throws Exception { PackageBuilder builder = new PackageBuilder(); Reader source = new StringReader( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<process xmlns=\"http://drools.org/drools-5.0/process\"\n" + " xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n" + " type=\"RuleFlow\" name=\"ruleflow\" id=\"com.sample.ruleflow\" package-name=\"com.sample\" >\n" + "\n" + " <header>\n" + " <variables>\n" + " <variable name=\"x\" >\n" + " <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n" + " <value></value>\n" + " </variable>\n" + " <variable name=\"m\" >\n" + " <type name=\"org.drools.process.core.datatype.impl.type.IntegerDataType\" />\n" + " <value></value>\n" + " </variable>\n" + " </variables>\n" + " </header>\n" + "\n" + " <nodes>\n" + " <start id=\"1\" name=\"Start\" />\n" + " <end id=\"3\" name=\"End\" terminate=\"false\"/>\n" + " </nodes>\n" + "\n" + " <connections>\n" + " <connection from=\"1\" to=\"3\" />\n" + " </connections>\n" + "\n" + "</process>"); builder.addRuleFlow(source); Package pkg = builder.getPackage(); RuleBase ruleBase = RuleBaseFactory.newRuleBase(); ruleBase.addPackage( pkg ); return ruleBase; } }

      I have a simple flow which includes some events. Main flow has Event Wait node and End node. When i get event I update session and Event Wait completes and reaches End node but process doesn't end, it remains active. I found a workaround - End node with Terminate=true. But it's not good for many situations, i have to add terminating End nodes to such flows and add some logic to check if all other paths ended...
      Is it expected behavior?

      Documentation is vague:
      An End node can be terminating for the entire process (default) or just for the path. If the process is terminated, all nodes that are still active (on parallel paths) in this ruleflow are cancelled. Non-terminating End nodes are simply ends for some path, while other parallel paths still continue.

      It's logical to expect process to end when all parallel paths end. But it doesn't end even with only one path!

              kverlaen@redhat.com Kris Verlaenen
              sydorenkoalex_jira Alexander Sydorenko (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: