2 Replies Latest reply on Apr 20, 2006 5:55 PM by Ronald van Kuijk

    How to end a ProcessInstance from an external process

    Jim McMaster Newbie

      I have a process definition that can run for a long time. I have a requirement to end it from another process, a web application running in the same JBoss container.

      This process definition has all failure transitions ending up at a "BatchComplete" node that saves some status to the database. What I would like to do is to end the process, but still execute the BatchComplete code after the ProcessInstance is ended.

      I have read the thread on stopping a process from last fall, but have a question about how processInstance.end() works.

      At what point does the end take effect? Is it immediate, or does the action for a Token's current Node have to finish before the Token ends?

      If the end does not take effect immediately, I need to wait for the process to complete before I can save the ending status. That is okay, but I do not want to add the complication if it is not necessary.

      Thanks for any help.

        • 1. Re: How to end a ProcessInstance from an external process
          Jim McMaster Newbie

          Is there really no one on this forum who can answer my question?

          Does a processInstance.end() cancel the process immediately? Or does it take effect when the currently processing node ends?

          This makes a big difference to me, because I have nodes with actions that can run more than an hour.

          • 2. Re: How to end a ProcessInstance from an external process
            Ronald van Kuijk Master

            There is a process-end event which (afaik) can be put on the process-definition itself. I would assume (but then again, i am not the expert) that that event would be called when the process ends. Even if it was via the processInstance.end() method. On that event you could call your own action.

            I'd like to stress some thing though. This project is open source. If you look at the source of ProcessInstance.end() you'd see the following:

             processDefinition.fireEvent(Event.EVENTTYPE_PROCESS_END, executionContext);
            


            et voila.... give it a try and you would not have had to wait 2 days for an answer.

            Ronald