7 Replies Latest reply on Sep 7, 2006 9:30 AM by tom.baeyens

    implementing undo

    tom.baeyens

      Someone wanted my ideas about how to start implementing undo in jBPM. So here goes:

      1) add a method in the LoggingSession called undo. The method should take a time (java.util.Date) to which the process should be rolled back. That method should first do a query on the database for all undoable process logs (that are not already undone) between now and the given date.

      That list of logs should be iterated in reverse order. On each processLog, an undo method should be called and the processLog should be marked as undone.

      In a first development iteration, you should focus on the rewinding the Node- and TransitionLogs so that the token is put back into the right location. The second thing would be undoing of the process variables. And then Task instances can be undone.

      2) The method undo should be added to ProcessLog

      3) An UndoableProcessLog should be created that allows users to add a log to a process execution with custom undo behaviour. This is to enable users to undo updates in their own domain model data.

      4) An interface UndoableActionHandler should be created that allows users to write undoable actions. jBPM could detect this with reflection and mark the ActionProcessLog as undoable.

      See also the related jira issue: http://jira.jboss.com/jira/browse/JBPM-589

      regards, tom.

        • 1. Re: implementing undo
          llucifer

          Will a process be undoable if the actionHandler does not implement UndoableActionHandler? If yes, I consider this dangerous because you easily oversee to rollback the process in the domain model data.

          • 2. Re: implementing undo
            tom.baeyens

            compensating transactions will always be dangerous. in the docs we will certainly put the necessary warning signs.

            but for certain use cases it makes sense, even though we cannot make it mathematically complete.

            the behaviour will be that the undo method will be called on every action that implements the Undoable interface.

            • 3. Re: implementing undo
              prassib

              Hi Tom, Is this the (your) code I should refer, to implement undo in jBPM?
              http://fisheye.labs.jboss.com/changelog/JBossJBPM?cs=MAIN:tombaeyens:20041006111829

              Your code looks good but I notice that you have your own implementation of ProcessInstance. I am working on jBPM 3.1.1.

              Also, I dont see many jBPM examples available on the internet besides yours. That makes me wonder if jBPM is actually being used to develop enterprise level work-flow applications?

              Any thoughts/advice would be greatly appreciated.

              • 4. Re: implementing undo
                kukeltje

                 

                Also, I dont see many jBPM examples available on the internet besides yours. That makes me wonder if jBPM is actually being used to develop enterprise level work-flow applications?


                We used staffware, used in lots of enterprises, but even less examples available on the internet. The fact that something is opensource does not mean things have to be published. It could also mean:
                - examples, besides the ones that are there, are not needed
                - 'other' examples are always specifc to a domain
                - people are not willing to share their processes (competitive advantage? certainly in enterprises)
                - ...

                Trust me, it is used in enterprise grade systems.

                • 5. Re: implementing undo
                  tom.baeyens

                  prassib, based on your pointer, i could find the actual file that contains the implementation of the undo method:

                  http://fisheye.labs.jboss.com/viewrep/JBossJBPM/jbpm.2/core/src/java/org/jbpm/impl/ExecutionServiceImpl.java?r=1.2

                  • 6. Re: implementing undo
                    prassib

                    Is there a way to prevent a ProcessInstance from not moving on to the next state despite it being signalled?

                    For example, I call the signal method on a ProcessInstance but can I write code inside any of the ActionHandlers to prevent the ProcessInstance from moving to the next state & continue to stay at the same state it was at.
                    In another words, I am trying to override the signal. Is it possible?

                    Thanks

                    • 7. Re: implementing undo
                      tom.baeyens

                      thow an exception in your action handler. client should then rollback.