12 Replies Latest reply on Nov 9, 2005 10:59 AM by kukeltje

    Restarting processes

    rslayer

      I am using jBPM to manage different macro-process tasks. I go through different nodes/tasks and perform different functions in a path i.e. the token. In the app one of the errors that can occur is when the app-server goes down and the tasks are left unfinished. Is there any way in jBPM to restart the process from where it left of? Does jBPM maintain state as it goes through the path/token so that if there is a connection drop or a failure, I can restart a process from its last saved state?

      any help will be appreciated.

        • 1. Re: Restarting processes
          tom.baeyens

          basically, jbpm goes from wait state to wait state in one transaction. so the process state is maintained in the db. so after a reboot, processes don't have to be restarted.

          regards, tom.

          • 2. Re: Restarting processes
            pksiv

             

            "tom.baeyens@jboss.com" wrote:
            basically, jbpm goes from wait state to wait state in one transaction. so the process state is maintained in the db. so after a reboot, processes don't have to be restarted.

            regards, tom.


            Tom,

            I was just out here looking for this exact answer and I haven't found this to be true in my tests.

            To be certain that I understand you. There is a simple process that transitions from state1 to state2 to state3. After state1 completes the process is transitioned to state2 but before state2 completes, the server comes down. Are you saying that state2 should re-run when the server comes back up ?



            • 3. Re: Restarting processes

              i thought hypersonicDB is a in-memory-engine which stores the states in the RAM. when is it written to the FS? do i have to call a certain method?

              cause if it stores in the ram, when server goes down in state 2 as mentioned there is no chance to regain the state...

              thanks

              dean_fry

              • 4. Re: Restarting processes
                kukeltje

                @pin:

                hsqldb can be either in memory or with file based persistency. It depends on how you configure it. See the hsqldb/jboss docs for this

                @pksiv:

                A state is a state and states themselves do not rerun. If there are some actions on state-enter events and the server goes down, the system stays in the previous state. I do not know however what happens if there are decisions in between.

                • 5. Re: Restarting processes
                  koen.aers

                  If there are decisions or other nodes in between and the transaction rolls back, all transactional stuff (database updates, sending messages) that has been issued by the actions executed going from one state to another and that occurs in the same global transaction, will rollback. If an action in between two states starts/commits its own transaction then this will not rollback automatically.

                  Regards,
                  Koen

                  • 6. Re: Restarting processes
                    kukeltje

                    does this mean that if I have tens of decisions (unlikely in a real world scenario) after eachother between two states, the transition from state 1 will only be completed if I have completely entered state 2?

                    • 7. Re: Restarting processes

                       

                      "kukeltje" wrote:
                      @pin:

                      hsqldb can be either in memory or with file based persistency. It depends on how you configure it. See the hsqldb/jboss docs for this


                      which document do you mean? "Chapter 6. Persistence" in the JBoss jBPM User Guide? can you give me a link to the hsqldb/jboss docs?

                      thank you very much!


                      • 8. Re: Restarting processes
                        kukeltje

                        if you use hibernate and not point to a jdbc datasource, use one of the connection urls in http://hsqldb.org/doc/guide/ch01.html#N1013D and put in the hibernate.cfg.xml.

                        If you use a datasource from the hibernate config, edit the datasource config in jboss. The same url definition is used in there. Only if you want hsqldb have a tcp listener you have to edit something more in jboss. See the hsql-ds.xml in the jboss server config for an example

                        • 9. Re: Restarting processes
                          pksiv

                           

                          "kukeltje" wrote:

                          @pksiv:

                          A state is a state and states themselves do not rerun. If there are some actions on state-enter events and the server goes down, the system stays in the previous state. I do not know however what happens if there are decisions in between.


                          Ok, so I have an Action on the node-enter event of a state and while this action is running, the server comes down. What state will the process be in (the one before the node-enter or the one containing the node-enter ?) and how do I get the process to start up again ?


                          • 10. Re: Restarting processes
                            kukeltje

                            the one before the node-enter afaik.

                            'starting it up' depends on what the trigger was to get it to enter this node. If it was a task in a previous node, that task is not completed since it is in the same transaction as the node-enter etc... if it was an async trigger (e.g. from a jms queue) you should make sure it is also takes place in the same transaction, is persisted etc. Then the process 'starts' again if the previous task is completed again or the trigger from the queue signals the state.

                            • 11. Re: Restarting processes
                              pksiv

                               

                              "kukeltje" wrote:
                              the one before the node-enter afaik.

                              'starting it up' depends on what the trigger was to get it to enter this node. If it was a task in a previous node, that task is not completed since it is in the same transaction as the node-enter etc... if it was an async trigger (e.g. from a jms queue) you should make sure it is also takes place in the same transaction, is persisted etc. Then the process 'starts' again if the previous task is completed again or the trigger from the queue signals the state.



                              Here's what I have and maybe you could offer suggestions on how I should set this up. There are no manual tasks. The first state writes a row to the database which will cause a DB trigger to be executed starting a long-running collection of Stored Procedures. This state is exited through a ctx.leaveNode("sucess") in the Action.

                              This transitions to another state with a node-enter Action which monitors a status table to determin if the StoredProcs have completed successfully or failed.

                              If the server is restarted during this second step, I need to get that Action running again to determine if the stored procs have completed.

                              <process-definition name='my process'>
                               <start-state>
                               <transition to='step1'/>
                               </start-state>
                               <state name='step1'>
                               <event type='node-enter'>
                               <action class='com.my.package.actions.InvokeTriggerAction'/>
                               </event>
                               <transition name='success' to='step2'/>
                               <transition name='fail' to='end'>
                               <action class='com.my.package.actions.FailAction'/>
                               </transition>
                               </state>
                               <state name='step2'>
                               <event type='node-enter'>
                               <action class='com.my.package.actions.CheckStatusAction'/>
                               </event>
                               <transition name='success' to='end'>
                               <action class='com.my.package.actions.SucceedAction'/>
                               </transition>
                               <transition name='fail' to='end'>
                               <action class='com.my.package.actions.FailAction'/>
                               </transition>
                               </state>
                               <end-state name='end'/>
                              </process-definition>
                              
                              


                              • 12. Re: Restarting processes
                                kukeltje

                                use the upcomming async functionality for actions in jBPM 3.1. It's exactely intended for these kinds of issues.