4 Replies Latest reply on May 20, 2008 4:56 AM by parchana

    How to persist the process state to DB before leaving each n

    parchana

      Hi,

      We have a JBPM process with multiple subprocesses, out of the subprocesses one process can run for number of days. Requirement is that we should persist the process state before leaving each and every node so that if JBoss server goes down in between the process can be re-triggered from the last executed state on server startup.

      I have read that JBPM persist the process state on wait nodes and when jbpmContext.close() is called.

      Now the problem is we have processes where there is no wait state and the requirement is state should get persisted even before jbpmContext.close(), so as to address recovery from fail-over on server shutdown.

      I have tried with following configuration file and managing transactions manually -

      <jbpm-configuration>
       <jbpm-context>
       <service name="persistence">
       <factory>
       <bean class="org.jbpm.persistence.db.DbPersistenceServiceFactory">
       <field name="isTransactionEnabled"><false/></field>
       </bean>
       </factory>
       </service>
       <service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />
       <service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
       <service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
       <service name="authentication" factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />
       <service name="tx" factory="org.jbpm.tx.TxServiceFactory" />
       </jbpm-context>
      </jbpm-configuration>
      

      Code for managing transaction is written in each ActionHandler as -
      public class MyActionHandler implements ActionHandler{
      
       public void execute(ExecutionContext context) {
       Transaction tx = null;
       try {
       tx = context.getJbpmContext().getSession().beginTransaction();
      //business logic in the action
       if(tx!=null)
       tx.commit();
       context.leaveNode();
       }
       catch(Exception e) {
       logger.error("Error: ",e);
       }
      }


      I can see an entry in jbpm_processInstance table after tx.commit() but when process fails in next node and I try to re-trigger the workflow from this last executed state - it says -
      org.jbpm.JbpmException: this token is locked by token[1063]
       at org.jbpm.graph.exe.Token.signal(Token.java:185)
       at org.jbpm.graph.exe.Token.signal(Token.java:140)



      Can anyone please help me in this?

      -Archana

        • 1. Re: How to persist the process state to DB before leaving ea
          kukeltje

          a subprocess without waitstates can 'run' thread for a number of days? that is not good process design. You'll run into threading issues, resource problems etc when you scale up. If some action can take long, use async nodes, the process is saved then (like you want) and the external trigger will make it continue

          • 2. Re: How to persist the process state to DB before leaving ea
            salaboy21

            kukeltje can you contact me to my private email?
            salaboy at gmail com...
            i dont find your real contact .. to contact you directly

            • 3. Re: How to persist the process state to DB before leaving ea
              parchana

              Hi Ronald,

              Thanks for the reply.

              We are using JBPM timer for long running processes. This timer creation node is a wait node so data gets persisted to the DB.

              We want data to be persisted for short running processes as well. There we can not use async nodes/actions as it affects execution sequence of nodes and we can not afford that. Also using wait nodes everywhere will degrade performance as it needs extra effort of triggering the workflows from outside (effort in creating and closing jbpmContext every time). Currently all nodes are executed one by one automatically.

              Is there any other way to persist process Instance data to database?

              Thanks,
              Archana

              • 4. Re: How to persist the process state to DB before leaving ea
                parchana

                Is there any difference in the way persistence takes place when using JBoss server separately compared to using Jboss server provided with jbpm-jpdl-3.2.2 suite?