[jboss-user] [jBPM Users] - Re: workflow design about wait states

mmusaji do-not-reply at jboss.com
Fri Sep 11 04:08:23 EDT 2009


Hi

Okay so here's my workflow.


  | <?xml version="1.0" encoding="UTF-8"?>
  | 
  | <process name="process" xmlns="http://jbpm.org/4.0/jpdl">
  |    <start>
  |       <transition to="parse request"/>
  |    </start>
  |    
  |    <custom class="org.application.workflow.ParseRequest" name="parse request" two="#{myObj}">
  |      <transition to="evaluate parse result"/>
  |    </custom>
  |    
  |    <decision name="evaluate parse result" expr="#{content}" >
  |      <transition name="valid" to="find providers"  />
  |      <transition name="invalid" to="error"/>
  |    </decision>
  |    
  |    <custom two="#{myObj}" class="org.application.workflow.FindProviders" name="find providers">
  |      <transition to="fork"/>
  |    </custom>
  |      
  |    <fork name="fork">
  |       <transition name="validate one" to="validate one request"/>
  |       <transition name="validate two" to="validate two request"/>
  |       <transition name="validate three" to="validate three request"/> 
  |    </fork>
  |    
  |    <!-- EACH OF THESE CUSTOM NODES WILL TAKE AN UNKNOWN AMOUNT OF TIME -->
  |    <custom continue="async" name="validate one request" class="org.application.workflow.ValidateoneFraudRequest" two="#{oneDetails}">
  |      <transition to="join"/>
  |    </custom>
  |    
  |    <custom continue="async" name="validate two request" class="org.application.workflow.ValidateExpFraudRequest" two="#{twoDetails}">         
  |     <transition to="join"/>
  |    </custom>
  |    
  |    <custom continue="async" name="validate three request" class="org.application.workflow.ValidateSysFraudRequest" two="#{threeDetails}">         
  |     <transition to="join"/>
  |    </custom>
  |    
  |    <!-- I WANT TO WAIT HERE UNTIL THEY ARE COMPLETE -->
  |    <state name="wait">
  |      <on event="fork">
  |        <event-listener class="org.application.workflow.WaitForValidation"/>
  |      </on>
  |     <transition to="join"/>
  |    </state> 
  |    
  |    <join name="join" continue="exclusive">
  |       <transition name="to evaluate validation results" to="evaluate validation results"/>
  |    </join>
  |    
  |    <decision name="evaluate validation results" expr="#{content}" >
  |      <transition name="valid" to="construct message"  />
  |      <transition name="invalid" to="error"/>
  |    </decision>
  |    
  |    <custom name="construct message" class="org.application.workflow.ConstructRequest" two="#{myObj}">         
  |     <transition to="send"/>
  |    </custom>
  |    
  |    <custom name="send" class="org.application.workflow.SendRequest" two="#{myObj}">         
  |     <transition to="get responses"/>
  |    </custom>
  |    
  |    <custom name="get responses" class="org.application.workflow.GetResponse" two="#{myObj}">         
  |     <transition to="process responses"/>
  |    </custom>
  |    
  |    <custom name="process responses" class="org.application.workflow.ProcessResponse" two="#{myObj}">         
  |      <transition to="getMyObject"/>
  |    </custom>
  |       
  |    <custom name="getMyObject" class="org.application.workflow.GetMyObject" two="#{myObj}">         
  |     <transition to="end"/>
  |    </custom>
  |    
  |    <task name="end">
  |       <transition name="to complete" to="end process"/>
  |    </task>
  |    
  |    <end name="end process" state="complete"/>
  |    <end-error name="error"/>
  | 
  |    </process>
  | 

This is my WebMethod. This is what starts the process when a request is recieved and will give a better idea of what I'm trying to achieve. I hope.

@WebMethod
  |     public String request() {
  |         try {
  |             InitialContext ctx = new InitialContext();
  |             this.processEngine = (ProcessEngine)ctx.lookup("java:/ProcessEngine");
  |             
  |             ExecutionService execService = (ExecutionService)
  |             this.processEngine.get(ExecutionService.class);
  |             
  |             ProcessInstance processInstance = execService.startProcessInstanceByKey("process", variables);
  | 
  |             System.out.println("ProcessInstanceID: " + processInstance.getId());
  |             //we need a signal cos we have no idea how long the return from the providers will take in real life
  |             Thread.sleep(3000);
  |             
  | //if I check this too early then I don't get the right details back
  |             oneDetails = (OneDetails)execService.getVariable(processInstance.getId(), "oneDetails");
  |             result = "OneDetails: " + oneDetails.getDetails();
  |             
  |         } catch (Exception e) {
  |             e.printStackTrace();
  |         }
  | 

Please explain further about signalling the specific state... which state? The one that is waiting for the processes in the fork to complete?

My Unit test which is attempting to signal the wait state is below. This isn't working at all at the moment.

  | public void testSimple() throws Exception {
  |         
  |         ProcessInstance processInstance = executionService.startProcessInstanceByKey("process", variables);
  |         String processInstanceId = processInstance.getId();
  |         
  |         Execution waitExecution = processInstance.findActiveExecutionIn("wait");
  |         executionService.signalExecutionById(waitExecution.getId());
  |                
  |         OneDetails oneDetails = (OneDetails )executionService.getVariable(processInstanceId, "oneDetails ");
  |     }
  | 

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4254663#4254663

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4254663



More information about the jboss-user mailing list