0 Replies Latest reply on Feb 2, 2007 9:51 AM by Eugene Prokopiev

    ?oncurrent workflow execution in separate threads

    Eugene Prokopiev Newbie

      Hi,

      Suppose, I have this simple workflow:

      <process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="0">
       <start-state name="start">
       <transition to="work"></transition>
       </start-state>
       <node name="save data to database">
       <action class="mypackage.DbSave"/>
       <transition to="end"></transition>
       </node>
       <end-state name="end"></end-state>
      </process-definition>
      


      It is possible to automatically execute it with this simple code:

      ProcessInstance processInstance = jbpmContext.getProcessInstance(id);
      Token token = processInstance.getRootToken();
      while(!processInstance.hasEnded()) {
       token.signal();
       jbpmContext.save(processInstance);
      }
      


      Sometimes workflow can include concurrent steps:

      <process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="0">
       <start-state name="start">
       <transition name="" to="fork"></transition>
       </start-state>
       <node name="save data to database 0">
       <action class="mypackage.DbSave0"/>
       <transition name="" to="join"></transition>
       </node>
       <node name="save data to database 1">
       <action class="mypackage.DbSave1"/>
       <transition name="" to="join"></transition>
       </node>
       <end-state name="end"></end-state>
       <fork name="fork">
       <transition to="save data to database 1"></transition>
       <transition to="save data to database 0"></transition>
       </fork>
       <join name="join">
       <transition to="end"></transition>
       </join>
      </process-definition>
      


      Is it possible to execute nodes "save data to database 0" and "save data to database 1" in separate threads?

      I tried to read chapter 9 (Process Modelling) and 13 (Asynchronous continuations) in User Guide about async node attribute, but I can't understand how can I write code to automatically execute such workflows.

      My questions are:

      1. How can I define jBPM Command Executor in standalone application and how to communicate between Command Executor main while cycle? How can this cycle looks like? Can anybody give me example code?

      2. Can I run different nodes concurrenly only with JMS thread pool?