Community

Handling process state

reply from David Jeeves in jBPM - View the full discussion

This is what i am running.

testFindOne suceeds as expected, but testFindTwo and testFindThree fail unless all three are run together( when they are run together they use the same processengine and execution service)

 

The bottom line is that findProcessInstanceById works only when the same processengine is used. But in the realworld after i recycle my application how will i be able to resume my incomplete processes?

========================================================================

public class TestJBPM extends TestCase
{
protected static ProcessEngine processEngine = null;

   protected static RepositoryService repositoryService;
   protected static ExecutionService executionService;
   protected static ManagementService managementService;
   protected static TaskService taskService;
   protected static HistoryService historyService;
   protected static IdentityService identityService;

   @Override
  protected void setUp() throws Exception {
     super.setUp();
      if (processEngine==null) {
          processEngine = Configuration.getProcessEngine();
         
          repositoryService = processEngine.get(RepositoryService.class);
          executionService = processEngine.getExecutionService();
          historyService = processEngine.getHistoryService();
          managementService = processEngine.getManagementService();
          taskService = processEngine.getTaskService();
          identityService = processEngine.getIdentityService();
        }
  }
   public void testFindOne() {
   
      repositoryService.createDeployment()
         .addResourceFromClasspath("com/test/Proc.jpdl.xml")
         .deploy();         
     
      ProcessInstance processInstance = executionService.startProcessInstanceByKey("Proc","t");
      System.out.println("process id  "+processInstance.getId());
     
      Execution executionInA = processInstance.findActiveExecutionIn("a");
      assertNotNull(executionInA);

      //processInstance = executionService.signalExecutionById(executionInA.getId());
      processInstance = executionService.findProcessInstanceById("Proc.t");
      assertNotNull(processInstance);                 
   }
   public void testFindTwo() {

      ProcessInstance processInstance = executionService.findProcessInstanceById("Proc.t");
      assertNotNull(processInstance);     
   
   }
   public void testFindThree() {
      repositoryService.createDeployment()
         .addResourceFromClasspath("com/test/Proc.jpdl.xml")
         .deploy();         
      ProcessInstance processInstance = executionService.findProcessInstanceById("Proc.t");
      assertNotNull(processInstance);     
   
   }  
     
  
 

}

===========================

The test process

=======================

<?xml version="1.0" encoding="UTF-8"?>

<process name="Proc" xmlns="http://jbpm.org/4.3/jpdl">
   <start name="start1" g="121,59,48,48">
      <transition name="to a" to="a" g="-25,-20"/>
   </start>
   <state name="a" g="107,134,92,52">
      <transition name="to b" to="b" g="-26,-20"/>
   </state>
   <state name="b" g="111,207,92,52">
      <transition name="to c" to="c" g="-25,-20"/>
   </state>
   <state name="c" g="118,271,92,52">
      <transition name="to end1" to="end1" g="-45,-20"/>
   </state>
   <end name="end1" g="134,344,48,48"/>
</process>

Reply to this message by going to Community

Start a new discussion in jBPM at Community