3 Replies Latest reply on Mar 27, 2007 10:45 AM by Ronald van Kuijk

    Best practices for cancelling a workflow

    Paul Farwell Newbie

      I need a way to cancel a workflow and have a handler fire, letting me know that the process was terminated abnormally. I'd like the handler to fire only when the process terminates in a non-standard way. For instance, I need to do some clean up of business code, clean up that I wouldn't have to do if the workflow ended normally.

      What's the recommended way to do this?

      I know about ProcessInstance.end(). Is there a way to create a handler or an event that let's me know (in Java code) when the workflow was terminated abnormally, ie. because of a call to end()?

      As an alternative, I can associate a Node named "cancel" with each step of the workflow, and signal each Task/Node/State to transition to the "cancel" node. But that seems clumsy - since I'd have to define a "cancel" step for every workflow and create a transition to it from every workflow node.

      A better way?

        • 1. Re: Best practices for cancelling a workflow
          dslevine Newbie

          I am handling this in my workflow application similar to the second way you are considering, by adding a "cancel" node and linking that with transitions. I only link it to the major nodes though, and assume that it can make it to a major node before being cancelled.

          I would be curious to hear others' design opinions on this topic.

          • 2. Re: Best practices for cancelling a workflow
            Richard Tomlinson Newbie

            I too am looking at the use of 'cancelling' a workflow.

            It appears its possible to cancel a task instance but there is no concept of cancelling a process instance or holding this state at the process instance that differentiates between normal and aborted termination of the process.

            Any suggestions as to the best way to implement this functionality?

            • 3. Re: Best practices for cancelling a workflow
              Ronald van Kuijk Master

               

              "CatlinIT" wrote:
              It appears its possible to cancel a task instance but there is no concept of cancelling a process instance


              May I ask where you got that impression from? I'm looking at the apidocs now and see a ProcessInstance.end() method

              "CatlinIT" wrote:
              or holding this state at the process instance that differentiates between normal and aborted termination of the process.


              Here you might be correct. I'm not sure it can be detected directly in which nodes the tokens were when they ended. OTOH, it might be possible to retrieve all tokens who have an end and ask in what node they were.. you do have to implement this yourself, but that is not to difficult