4 Replies Latest reply on Jun 21, 2010 5:09 AM by swiderski.maciej

    The external Trigger makes the transition from subprocess node to the next node while subprocess is active.

    felixkjose

      Hi All,

       

      I was using the "SubProcessDocument.jpdl.xml" and "SubProcessReview.jpdl.xml" from the "examples\src\org\jbpm\examples\subprocess\outcomeactivity" given in the jbpm-4.3 examples. In my sample program I have done

       

      ProcessInstance processInstance =executionService.startProcessInstanceByKey("SubProcessDocument");

      assertNotNull(processInstance.findActiveExecutionIn("review"));

       

      Also I have checked the sub process and main process ids by:

       

      ExecutionImpl executionImpl = (ExecutionImpl) processInstance;

      System.

      out.println("Exec Id =" + executionImpl.getId());

      ExecutionImpl subExecutionImpl = executionImpl.getSubProcessInstance();

      System.

      out.println("subExecutionImpl==" + subExecutionImpl); ---both ids are different.

       

      //signaling from sub process state node ("review") to "next step" node

      processInstance = executionService.signalExecutionById(processInstance.getId());

       

      executionService

       

      .findProcessInstanceById(processInstance.getId());

      assertNotNull(processInstance.findActiveExecutionIn(

      "next step"));

       

       

      So the transition is happend from "review" to "next step" instead of waiting for the output from the SubProcessReview subprocess.

       

      Is this an expected result ?

      or whether the main execution should not be able to transition from subprocess state to next state untill and unless the subprocess execution is completed?

      Why it is like that?

       

      Can anybody please give your thoughts on the same?

       

      Thank you and Regards,

      Felix K Jose

        • 1. Re: The external Trigger makes the transition from subprocess node to the next node while subprocess is active.
          swiderski.maciej

          Hi,

           

          this is incorrect behavior and it was already fixed in 4.4, please take a look at following issue: https://jira.jboss.org/browse/JBPM-2874

          • 2. Re: The external Trigger makes the transition from subprocess node to the next node while subprocess is active.
            felixkjose

            Hi Maceij,

             

            Thank you for your reply. The JBPM-2874,  the test case "testSubProcessWithStateFailure" is making the transition from the subprocess node to the next node using the main process instance id while the subprocess is in "wait" state. And then checking the process stateagainst the subprocess state. And my doubt is why the JBPM is not throwing any exception? Because

            1. The sub process is in active state(wait state).
            2. The main process is not making the transition over the sub process nodes.

             

            So whether only a state check will do the solution or make a change in the implementation class of executionService's "signalExecutionById" method to check the subprocess instance is active or not and throw an exception saying the "Invalid transition. Subprocess [subprocess id =<Sub 19>] is active." while the sub process is active.

            And should not able to transition from sub process node to next node.

             

            Please let me know about your thoughts on the same.

             

            By using ExecutionImpl I am getting the subprocess Id and using that I am able to transition through the subprocess nodes.

             

            ExecutionImpl subExecutionImpl = executionImpl.getSubProcessInstance();

            executionService.signalExecutionById(subExecutionImpl.getId());

             

            But please let me know how the ExecutionImpl will do the workaround?

             

            Because by using the ExecutionImpl I can get the subprocessId and main processId. But when I am doing a transition (

            executionService.signalExecutionById(executionImpl.getId()) ) from subprocess node to the next node, it is happening successfully, while the subprocess is active(wait). This is not the intended output.

            The expected result in this case is "throw an exception saying the "Invalid transition. Subprocess [subprocess id =<Sub 19>] is active."

             

            Please give me a reply regarding this as soon as possible.

             

            Thank You and Regards,

            Felix K Jose

            • 3. Re: The external Trigger makes the transition from subprocess node to the next node while subprocess is active.
              rebody

              Sorry, Wrong again. Maciej please execute me.

               

              I should look into patch.  not only see the SubProcessSignalTest.java

               

               

              The final version of testSubProcessWithStateFailure is here;

               

              public void testSubProcessWithStateFailure() {
                  deployJpdlXmlString(SUB_PROCESS_WITH_WAIT_STATE);
                  deployJpdlXmlString(MAIN_PROCESS_SUB_EL_ID);
                  
                  Map<String, String> vars = new HashMap<String, String>();
                  vars.put("dynamic_subprocess", "SubProcessReview-1");
                
                  ProcessInstance processInstance = executionService.startProcessInstanceByKey("mainProcess", vars);
                 
                  try {
                    processInstance = executionService.signalExecutionById(processInstance.getId());
                    
                    fail("Should fail since signal was made on a process with subprocess stil active");
                   } catch (Exception e) {
                     
                     //expected exception since we are signaling main process while sub process is not finished
                     assertTrue(e.getMessage().indexOf("has running subprocess") != -1);
                     
                     // clean up to let other tests execute
                     executionService.signalExecutionById(processInstance.getSubProcessInstance().getId());
                     executionService.signalExecutionById(processInstance.getSubProcessInstance().getId());
                     
                     processInstance = executionService.signalExecutionById(processInstance.getId());
                     
                  }
                  
                }
              

               

              We can see if there is an active sub process ,there will be an exception.  Thank you Maciej for correcting me.

              • 4. Re: The external Trigger makes the transition from subprocess node to the next node while subprocess is active.
                swiderski.maciej

                The fix will do what you expect. In case of signal of main process while sub process is still running it will throw an exception that main process is not active.

                In addition, since 4.4 there will be API method exposing subprocess instance so you will not need to use internal classes to get hold of this information.