2 Replies Latest reply on May 14, 2015 11:20 AM by Jie Lin

    Restoring global and local variables in jBPM process instance after restarting JBOSS server

    Jie Lin Newbie

      Is there a way to restore global and local variables (persist state) in jBPM 6.2 process instance after restarting JBOSS server?

      To give a little more background, we are configuring jBPM settings using Spring. Through a web service call, we are starting the jBPM workflow. Then we restart the jBoss server. After that, through another web service call we would like to continue the workflow from where it left off. But the problem is how can we restore the session?

      We are currently trying to use the following StatefulKnowledgeSession to persist local and global variables as follows:

      Environment env = KnowledgeBaseFactory.newEnvironment();

      env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, jbpmEMF);

      KieHelper kieHelper = new KieHelper();

      KieBase kbase = kieHelper.addResource(ResourceFactory.newClassPathResource("workflow.bpmn")).build();

      // create a new knowledge session that uses JPA to store the runtime state

      StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);

      To restore the session, I'm using

      KieSession ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(123, kbase, null, env );.

      Is this the correct approach?

        • 1. Re: Restoring global and local variables in jBPM process instance after restarting JBOSS server
          Maciej Swiderski Master

          if you run processes you should either use runtime manager api or jbpm services (from 6.2 onward)


          Here you can find some articles about both approaches:

          - cross framework services

          - samples with runtime manager api



          • 2. Re: Restoring global and local variables in jBPM process instance after restarting JBOSS server
            Jie Lin Newbie

            Thank you Maciej for the response. I don't think I've explained my problem well. Let me provide more details below.


            We are currently using the runtime manager api to run processes in jBPM 6.2 using Spring to autowire the runtimeManager object. However, we're having trouble understanding how we can restore the I/O mapping variables and global variables in our process once we restart the jBoss server.


            As an example, in the evaluation bpmn file that involves the user krisv, the HR, and the PM, the variables 'reason' and 'performance' are passed from the user krisv to both the HR and the PM. Now suppose we are using a web service to complete each of these user tasks. Right after the web service call for krisv, we have 'reason' with value 'Yearly performance evaluation' and 'performance' with value 'exceeding'.


            Now the jBOSS server containing the our deployed jBPM application restarts. After restart, we send a web service call to the HR to check the previous values of 'performance' (ie: check for validation), but this value seems not to be persisted in the application (ie. has the value 'null').


            So is there an API in jBPM 6.2 that we can use to restore the global and local variables (I/O mapping variables) to values prior to the server restart?


            Additional details:

            1. We are not using KIE workbench console. We are directly deploying the jBPM application through Eclipse.

            2. We are loading the entity manager factory, JtaTransactionManager, runtimeEnvironment, runtimeManager through Spring autowiring.


            I alse see that these local variables are persisted in the table VariableInstanceLog, but not sure what API in jBPM 6.2 we can use to restore those variable values.