2 Replies Latest reply on Mar 9, 2006 8:06 PM by enazareno

    How to rollback failed timer.execute

    enazareno

      Dear All,

      How do we rollback a transaction just in case a timer execute method fails in the scheduler session? We do not want to rollback the entire scheduler session, just the failed timer. I was thinking of creating two sessions, one to lookup the timers and another to do the execution persistence, however there is no method to lookup a timer based on its id. If somebody has already a solution for this, I'd appreciate if you can share your expertise or if this has already been discussed, kindly point me to that post. Thanks a lot.

      Regards,

      Elmo

        • 1. Re: How to rollback failed timer.execute
          tom.baeyens

          the current impl of the timer executor will rollback the transaction if an exception comes out of the timer execution.

          does that answer your question ?

          regards, tom.

          • 2. Re: How to rollback failed timer.execute
            enazareno

            Hi Tom,

            Thanks for the reply. I am using 3.1 and in my design, I have wrapped JBpm in session beans and as I have experienced, I need to add a setRollbackOnly to make effective rollbacks to the process instance. I am assuming also that the close statement in the context will flush and commit the data ( Is this assumption correct?)

            Anyway, in my design for the timer, the scheduler thread is still in the servlet. I had to copy and paste your executeTimers code into a session bean which is called by the servlet. I have seen in the code that there is no setRollbackOnly only a close statement. What is the correct behavior in this scenario: I have 20 timer tasks in a scheduled run. The first 10 timers have already executed correctly. If I abort the process, which means it was not able to close the context, am I guaranteed that the 10 timers will have already committed or will it rollback?

            P.S. This arose because as I was testing a state having two timers, wherein 1 timer cancelled the other timer, the other timer was not deleted in the database. To correct the situation, I had to do an extra save processInstance in the executeTimers method. Simply calling saveTimer seems to not save the other cancelled or deleted timers.

            Regards,

            Elmo