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

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

    Archana Pawar Newbie


      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 -

       <service name="persistence">
       <bean class="org.jbpm.persistence.db.DbPersistenceServiceFactory">
       <field name="isTransactionEnabled"><false/></field>
       <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" />

      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
       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?