12 Replies Latest reply on Mar 27, 2015 7:37 PM by tujasiri

    Restore JBPM session



      I am new to JBPM and struggling to understand the flow.............


      I red that we can store jbpm session,process instance,task instance and variables...etc...............


      After some point, assume application crashes and want to restore all running sessions how would i do?


      Do i need to get each process id/session id from the session and again start it?

      If i do in the above way, from which point it will start the session like it already proesses two nodes....How it will know to start from node3? Do i need to configure that also. If how would i?


      Also red in discussions that after restoring the session, we need to again register action handlers? Is it true?





      What is the use task server ,task service and task client? How they are different from workitem handler?


      Please reply.............................................

        • 1. Re: Restore JBPM session

          I am also very much interested the answers for new bee's questions. Please reply for the clear understanding of JBPM5.

          • 2. Re: Restore JBPM session



            What database do you use for the JBPM?


            If you changed the default H2 Database to some other DB like MySQL or SQL Server, all the process instances data will be stored in the DB. so in the event of application crash, when you restart the application, the process instances data is still there in the Database.




            Thomas Setiabudi

            • 3. Re: Restore JBPM session

              I am aware that it will store process instance info in database........

              But my question is, how it will restart incomplete processes? Where do we need to give configuration?


              Do we need to explicitly write one more class to restart all incomplete processes after fetchin info from database?

              • 4. Re: Restore JBPM session

                I think the process should continue from before application crash point.


                Lets take the com.sample.evaluation included in the jbpm5.3 full installer.


                First step, we initiate the process instance lets say we pass in krisv as the employee name

                Second step, krisv look at his task list and then complete his task

                Third step, john look at his task list and then complete his task

                Fourth step, Mary look at her task list, but when she tries to complete her task, application crash.


                so we stop everything and restart


                After restart, Mary should be able to see the task in the task list and complete it.


                Isn't that the default behavior right now? Or do I misunderstand your question?



                Thomas Setiabudi

                • 5. Re: Restore JBPM session

                  Hi Thomas,

                  I am very thankful for your time.

                  You are giving the ideal behavior of workflow....

                  My question is, how it will know the restart point(The node where to start process again)........If it stores in database,what is the schema structure?



                  What if i don't want to restart incomplete processes...What shall i do?


                  As i told u, i am new one trying to understand work flow......Please help me in this aspect....

                  • 6. Re: Restore JBPM session

                    Hi new bee,


                    Have you tried to change the default H2 Database to some other Database like MySQL or SQL Server?

                    If you want to know the Database Schema structure, it is a good idea to do that since you will be able to see all the tables.


                    If you do not want to restart incomplete process, you can terminate the process and then start a new instance of the process.




                    Thomas Setiabudi

                    • 7. Re: Restore JBPM session

                      Hi new bee,


                      JBPM do not provide automatic restore of process and session on server restart :-(

                      You have write your own management code for this service.

                      You will need to read process id of pending complete workItem and restart the process yourself.

                      Never process can only be started once. If process was in progress when server restarted then you can not start process again.

                      Yo can find out the last workItem and complete it by this code

                      ksession.getWorkItemManager().completeWorkItem(workItemId, null);

                      Once the workItem is complete the flow will process to next workItem.


                      Study this to restore session:


                      StatefulKnowledgeSession org.drools.persistence.jpa.JPAKnowledgeService.loadStatefulKnowledgeSession(int id, KnowledgeBase kbase, KnowledgeSessionConfiguration configuration, Environment environment)

                      • 8. Re: Restore JBPM session

                        Hi new bee

                        I had similar problem so that after an application server crash I couldn't resume my processes unless I start a new process ! for start a new process I need to initialize a new StatefulKnowledgeSession. so after such initialization I can resume my old processes.


                        Hope this helps


                        • 9. Re: Restore JBPM session

                          What are best practices for storing SessionID?


                          I am using Spring and my KnowledgeSession is defined as follows:


                            <jbpm:ksession id="ksession" type="stateful" kbase="kbase" >



                                  <jbpm:transaction-manager ref="txManager"/>

                                  <jbpm:entity-manager-factory ref="myEmf"/>




                          When I restart server, new SessionID is generated and I am able to retreive User tasks with this new SessionID.


                          Is this appropriate way to restore session, or some other mechanism (custom Session Managment) must be employed?

                          • 10. Re: Restore JBPM session

                            we have a singleton service holding a single session for workflows, everytime the server stopps a new session is created, I am not sure if this is the best approach, but it is working well for us, the only issue is that the DB gets populated with sessions that are not used anymore.


                            We have human tasks in the processes and as they are also persisted, after a server stop (or node "change" in a cluster) jbpm is able resume the workflow after completing the task.

                            The problem of resuming the process has been submitted as jira here (they also describe a workaround there):


                            • 11. Re: Restore JBPM session

                              sorry, can you descibe in a simpler way the workaround described?




                              • 12. Re: Restore JBPM session



                                I'm unable to find any code illustrating how you can use persistence to restart/resume a failed node.  Please show me some examples that would allow me to do this.  I've done everything here -- Chapter 8. Persistence and Transactions -- and my test program with two nodes --  -- works after persistence configurations have been done.  However, I Have no idea how to implement the persistence tools to restart a failed process.