9 Replies Latest reply on Aug 3, 2010 7:08 AM by Puneet Kankane

    How to handle failed processes/states due to server crashes?

    Puneet Kankane Newbie

      Hi,

       

      I have a Spring 3.0 + jBPM 4.3 setup, basically a webapplication with embedded jBPM.

       

      Basic flow of my application:

      On receiving a message on queue, my application creates a process instance based on the process name within message.

      Once started my processes interact with other services(SLSB invoked by MDrivenBeans) through jms.

       

      I would like to know how I can handle scenarios like:

       

      1. Failed process states due to any server crash. How can I restart the processes from the point where they failed?

      2. How will transaction be rolled back once my application is up again?

      3. How shall I do Exception Handling? May be Custom node? I know this has been asked in other threads too, but I asking it here also because: a) since I am new to jBPM I am not able to understand it, may be a sample example would do. b) I feel exception handling needs to be taken care in such a application where we are interacting with jms & other external services.

       

      Please guide me by helping me understand jBPM in such scenarios. I want to build a scalable solution for my project.

       

      Thanks in advance,

       

      Puneet

        • 1. Re: How to handle failed processes/states due to server crashes?
          Michael Wohlfart Expert

          Hi,

          1. Failed process states due to any server crash. How can I restart the processes from the point where they failed?

          The processes are executed within a database transaction until they reach some kind of wait state where they need input (signals) in order to continuethis state is persisted to database, I don't see any reason for restarting a process here.

          2. How will transaction be rolled back once my application is up again?

          That's the job of the database as far as i understand.

          3. How shall I do Exception Handling? May be Custom node? I know this has been asked in other threads too, but I asking it here also because: a) since I am new to jBPM I am not able to understand it, may be a sample example would do. b) I feel exception handling needs to be taken care in such a application where we are interacting with jms & other external services.

          That's the job of the user code, you have to deal with your own Exceptions, there is no special Exception Handling besides some obvious stuff like rollback of the ongoing transaction. And then there is some retry code for failed async Job execution and a Retry interceptor for stale hibernate entities.

          1 of 1 people found this helpful
          • 2. Re: How to handle failed processes/states due to server crashes?
            Michael Rinne Newbie

            Hi,

             

            Concerning exception handling, I saw that advice to take care of exceptions in the user code a couple of times in this forum, but I am not totally convinced that this is capable to handle all cases that arise in BPM.

             

            Let us assume I have a process definition containing the sequence state1 -> task1 -> task2 -> state2. Let us further assume there is some sort of dependency between task1 and task2, i.e. if task2 fails we have to perform some kind of undo for task1. If I handle exceptions within the user code for task2 I am not able to undo task1, because I do not want task2 to know about task1. For the same reason, I do not want to combine task1 and task2 into a single task.

             

            The solution in jpdl 4 seems to be adding another transition from task2 to a task "undo_task1" and any exception in task2 will make sure that we take the transition to "undo_task1". Another transition from "undo_task1" will lead back to state1 and of course we add a decision in order to prevent processing from taking this circle endlessly.

             

            However, an exception-handler as provided by jpdl 3 seems to be a convenient way to handle most exceptions on a BPM scale, although it will most likely not be as flexible as the explicit solution sketched above.

             

            What are you opinions on this?

            Does anyone have a better idea on how to do exception handling on BPM scale with jpdl 4?

             

            Thanks,

            Michael

            • 3. Re: How to handle failed processes/states due to server crashes?
              Puneet Kankane Newbie

              That's the job of the user code, you have to deal with your own Exceptions, there is no special Exception Handling besides some obvious stuff like rollback of the ongoing transaction. And then there is some retry code for failed async Job execution and a Retry interceptor for stale hibernate entities.

              Michael thanks for your reply.

               

              I am not using async job execution, I have wait states, waiting for a reply from a service. "some obvious stuff like rollback of the ongoing transaction" - how will the transaction rollback if the application shutsdown gracefully or crashes.

               

              Retry-Interceptor : - could you please provide more insight on this. any pointers on how to make best use of them and when should we use them.

               

              Puneet

              • 4. Re: How to handle failed processes/states due to server crashes?
                Michael Wohlfart Expert

                I am not using async job execution, I have wait states, waiting for a reply from a service. "some obvious stuff like rollback of the ongoing transaction" - how will the transaction rollback if the application shutsdown gracefully or crashes.

                When your execution reaches the wait state the transaction is committed, there is no need to rollback just because of a shutdown, after bootup jBPM4 picks up your wait state and still waits for a signal, maybe I miss the point here but I don't see a reason to rollback because of a graceful shutdown? In case of a crash the normal transaction handling in your database or on the jdbc or hibernate level rolls back the changes, just like in any other database application.

                Retry-Interceptor : - could you please provide more insight on this. any pointers on how to make best use of them and when should we use them.

                 

                the retry-interceptor is what you configure in your command service, see the dev guide (6.7 Services):

                http://docs.jboss.com/jbpm/v4/devguide/html_single/

                it's ment for catching hibernate StaleObjectExceptions but I still get those Exceptions so it seems like it doesn't work in all cases...

                • 5. Re: How to handle failed processes/states due to server crashes?
                  Puneet Kankane Newbie
                  after bootup jBPM4 picks up your wait state and still waits for a signal

                   

                  Correct me I am wrong: Will jBPM4 pick up the processes waiting for a signal if it (jBPM) is embedded in my application only as a lib rather than installed as a service on JBoss. If thats the case then once my spring-jbpm context gets loaded on application start up, jBPM should pick up all the nodes and wait for a signal.

                   

                  the retry-interceptor is what you configure in your command service, see the dev guide (6.7 Services):

                  http://docs.jboss.com/jbpm/v4/devguide/html_single/

                  it's ment for catching hibernate StaleObjectExceptions but I still get those Exceptions so it seems like it doesn't work in all cases...

                   

                  theory in devguide doesn't provide much explanation of retry interceptor. I mean how to configure, what inputs it will need and such thing. Do we have any example available for retry-interceptor.

                   

                  Puneet

                  • 6. Re: How to handle failed processes/states due to server crashes?
                    Michael Wohlfart Expert
                    Correct me I am wrong: Will jBPM4 pick up the processes waiting for a signal if it (jBPM) is embedded in my application only as a lib rather than installed as a service on JBoss. If thats the case then once my spring-jbpm context gets loaded on application start up, jBPM should pick up all the nodes and wait for a signal.

                    that's correct the state of your processes is persisted in the database and preserved between reboots, and that should work weather you use the jBoss Service or not, when you signal jBPM looks up the database for your process instance and wait state...

                    theory in devguide doesn't provide much explanation of retry interceptor. I mean how to configure, what inputs it will need and such thing. Do we have any example available for retry-interceptor.

                    i guess you assume the retry-interceptor is more than it actually is, it's  just a try/catch and checks for StaleStateException, you can configure retries, delay and delay-factor, check the sourcecode I haven't seen it's config options documented somewhere

                    • 7. Re: How to handle failed processes/states due to server crashes?
                      Puneet Kankane Newbie

                      Hi Rinne,

                       

                      While trying to find out out what else could be done for exception handling in jBPM 4, I came across this article: http://www.schabell.org/2009/12/custom-jbpm-exception-framework-for.html. It talks about the exception framework, though implemented in jBPM 3.2.

                       

                      We could come up with something similar using this concept for jBPM 4.x.

                       

                      Hope this helps you & me.

                       

                      Puneet

                      • 8. Re: How to handle failed processes/states due to server crashes?
                        Michael Wohlfart Expert

                        I just noticed there is actually ExceptionHandling code in jBPM4 like

                        org.jbpm.pvm.internal.builder.ExceptionHandlerBuilder or org.jbpm.pvm.internal.model.ExceptionHandlerImpl

                        but I haven't found any documentation about this

                        • 9. Re: How to handle failed processes/states due to server crashes?
                          Puneet Kankane Newbie

                          But these are used internally by ExecutionImpl & ProcessElementImpl not many implementation available.

                           

                          Puneet