6 Replies Latest reply on Feb 25, 2010 2:10 PM by swiderski.maciej

    How to handle rollback due to runtime errors

    swiderski.maciej

      Hi all,

       

      in one of recent posts I have been interesting discussion going on about exception handling in jBPM. As it was described there user code exception should be handled within that code but what about case where user code was executed fine but something else went wrong?

       

      Please consider following scenario:

      - there are 4 nodes (regardless of type) that are executed as one transaction.

      - some of the nodes modify external systems via different protocols

      - no exceptions are thrown from nodes

      - runtime exception is thrown due to some db issues

       

      Transactionwill be rolled back but changes made to external system are not rolledback since they were not part of the transaction (for example webservice call).

       

      Have you put any thoughts into that? I was wondering if some sort of compensation mechanism could be introduced to the execution where nodes that take part in transaction can inform runtime engine what to invoke in case of roll backs. This could give kind of undo operation for already finished nodes and should not cause any problems when process will go thru them again.

       

      What's your opinion about it? Does it sound reasonable?

       

      Cheers,

      Maciej

        • 1. Re: How to handle rollback due to runtime errors
          kukeltje

          Yes there has been ideas in this area... In fact jBPM 2.0 had some functionality for 'compensating' actions. It was not in the next release since it was way to difficult to fully support all kinds of compensations and have the right information available.  E.g. the jBPM task that was to be rolled back should have the 'previous' data, but if, like you say, e.g. the relevant DB is not available, how can that be accessed?And this is just one of a multitude of problems.

           

          That is specifically the reason I would not, (really not) use plain webservices in enterprise grade systems other than simply querying e.g. a usermanagement system. All other kinds of access to external/different systems should either go through transaction aware protocols or should be capable to receive the same data twice if e.g. the activity is executed again.

           

          All these things are 'good habits' in designing systems and one of the reasons webservices did not really take off (have you seen a webservice library that could participate in a JTA transaction? (e.g. as a JCA module) And if you have, could the receiving party handle ws-transactions?

           

          So your question is a valid and understandable one, but the solution is not within jBPM but e.g. http://jboss.org/jbosstm (but that is JBoss specific)

           

          Cheers,

           

          Ronald

          • 2. Re: How to handle rollback due to runtime errors
            swiderski.maciej

            I agree with you that it would be best to enclose all executions in transaction aware protocols but that is not always the case. For Web Service calls there are more and more implementations that supports various WS-* extensions and as you mentioned JBoss Transaction has support for that as well.

            My example was more to illustrate that there could be a case where we would like to call another process on another machine using completely different process engine/framework so we cannot have a transaction over it. What I would like to have is a minimal notification for user code in case of transaction rollback to be able to gracefully handle that, for instance to suspend/cancel process running somewhere else.

             

            From what you said, I assume that there won't be any solution for that?!

             

            Cheers,

            Maciej

            • 3. Re: How to handle rollback due to runtime errors
              kukeltje

              I understand your usecase, functionality wise. On the other hand, I'm almost 100% sure that the separate WS-hell will not become realy major in complex B2B things. Other protocols are better suited for that

               

              If we would provide something 'simple' for that, people most likely want more, but.... BPMN has an explicit ERROR event, not sure how that is to be used (see the specs for that http://www.omg.org/spec/BPMN/2.0/) and when in jBPM will have support for it.

               

              Regarding transaction-rollback, intercepting those in a process somewhere when things happen low level and acting on it is (I think, am not into that low level stuff) rather difficult. Otoh, jBPM can already be used with some interceptors, so maybe you can do something on that level.

               

              Personally, I've never really missed it (just did not use basic webservices )

               

              Ronald

              • 4. Re: How to handle rollback due to runtime errors
                swiderski.maciej

                Error events in BPMN 2.0 seems more like activity specific but I found something about boundary error events so that could be what I am looking for but as you mentioned there is not time frame for that to be implemented at the moment.

                 

                Interceptors sounds quite nice, I must admit. Could you please provide some more details about it?

                Are they configurable or does it require to modify jBPM code?

                 

                Thanks

                Maciej

                • 5. Re: How to handle rollback due to runtime errors
                  kukeltje

                  Interceptors sounds quite nice, I must admit. Could you please provide some more details about it?

                  Are they configurable or does it require to modify jBPM code?

                   

                   

                  I have no real knowledge of this, nor the time to find out, sorry. Best is to look in the source on how things are done...

                   

                  Ronald

                  • 6. Re: How to handle rollback due to runtime errors
                    swiderski.maciej

                    No problem Ronald, thanks a lot for all the help with this issue. Will look into the source and if I find something will post it back here.

                     

                    Cheers,

                    Maciej