4 Replies Latest reply on Nov 13, 2006 3:04 AM by jing gu

    understand asynchronous continuations

    jing gu Newbie

      hello every,
      I am a new jbpm comer, and reading the userguide page by page. howevery, i tried my best but could not understand the meaning of "asynchronous continuations", could any one help me about it and examples are great.
      here is my simplest example:

      <?xml version="1.0" encoding="UTF-8"?>
      <process-definition name="sub">
       <start-state name="start">
       <transition to='wait' />
       <state name="wait" async='true' >
       <transition to='end' />
       <end-state name="end" />

       ProcessInstance processInstance =
       new ProcessInstance(processDefinition);
      JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
      Token token= processInstance.getRootToken();

      what is the different with/without " async='true' "

        • 1. Re: understand asynchronous continuations
          Tom Baeyens Master

          when invoking the signal method, the process will start executing and this method only returns after the process has entered a new wait state. potentially this means that many nodes are executed in the mean time.

          all of this is inside 1 transaction of the caller of the signal method.

          asynchronous continuations lets you execute the process till a certain point (the node marked with async=true) in the caller's transaction. then jbpm will take care of resuming the execution in a separate transaction. this involves sending an asynchronous message in the caller's transaction to a job executor. the job executor will start a new tx and resume the execution starting by execting the node with async=true

          let us know if this explanation is better then in the user guide, then we update it :-)

          • 2. Re: understand asynchronous continuations
            jing gu Newbie

            thanks for the reply, does that mean asynchronous continuations is useful for the node typed Node, not for the node typed state because state node is only a wait state?

            • 4. Re: understand asynchronous continuations
              jing gu Newbie

              now i am continue to my test.
              i want to know how to activate a message executor?

              <process-definition name="sub">
               <start-state name="start">
               <transition to='auto' />
               <node name="auto" async='true' >
               <action class="example.processmodel.NodeExecuteHandler" />
               <transition name="endtran" to='end' />
               <end-state name="end" />

               JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
               Token token= processInstance.getRootToken();

              public class NodeExecuteHandler implements ActionHandler {
               public void execute(ExecutionContext executionContext) throws Exception {
               // TODO Auto-generated method stub

              It seems the example.processmodel.NodeExecuteHandler has not been execute as i could not see the system out.And i looked up in the database table jbpm.jbpm_message and saw
              1, 'N', 'CMD_EXECUTOR', '', 0, 1, '', , 2, '',
              the config:
              static JbpmConfiguration jbpmConfiguration = null;
               static {
               // An example configuration file such as this can be found in
               // 'src/config.files'. Typically the configuration information is in the
               // resource file 'jbpm.cfg.xml', but here we pass in the configuration
               // information as an XML string.
               // First we create a JbpmConfiguration statically. One JbpmConfiguration
               // can be used for all threads in the system, that is why we can safely
               // make it static.
               jbpmConfiguration = JbpmConfiguration.parseXmlString(
               "<jbpm-configuration>" +
               // A jbpm-context mechanism separates the jbpm core
               // engine from the services that jbpm uses from
               // the environment.
               " <jbpm-context>" +
               " <service name='persistence' " +
               " factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />" +
               " <service name='message' " +
               " factory='org.jbpm.msg.db.DbMessageServiceFactory' />" +
               " </jbpm-context>" +
               // Also all the resource files that are used by jbpm are
               // referenced from the jbpm.cfg.xml
               " <string name='resource.hibernate.cfg.xml' " +
               " value='hibernate.cfg.xml' />" +
               " <string name='resource.business.calendar' " +
               " value='org/jbpm/calendar/jbpm.business.calendar.properties' />" +
               " <string name='resource.default.modules' " +
               " value='org/jbpm/graph/def/jbpm.default.modules.properties' />" +
               " <string name='resource.converter' " +
               " value='org/jbpm/db/hibernate/jbpm.converter.properties' />" +
               " <string name='resource.action.types' " +
               " value='org/jbpm/graph/action/action.types.xml' />" +
               " <string name='resource.node.types' " +
               " value='org/jbpm/graph/node/node.types.xml' />" +
               " <string name='resource.varmapping' " +
               " value='org/jbpm/context/exe/jbpm.varmapping.xml' />" +

              but how to config a command executor?both in pure java application and in
              application server. thanks for help~