Cancel a process that is 'hung'

I’m trying to provide a last-resort option to end a process that is not finishing normally using a ‘force-close’ button on my UI that will execute java code to end the process.

One possible cause of the stoppage is a message task that never receives it’s message. I can’t use a timer event so I tried to put a boundary cancel event on the message task. However, when I try to fire the abort signal (using runtimeService.signalEventReceived(“abort”)), there are no subscribers and the catching event is never triggered.

There may be other reasons for the stoppage that I have not found yet. It is a vary large process with many sub-process and Service Tasks. So I would prefer a solution that would be implemented at the top level process that would trigger the termination of any running process.

What is the best practice for this?



Be careful with the signals, because potentially you can end up cancelling all the process instances waiting in that activity. For that kind of purpose, it’s better to use (BPMN) messages (process instance specific). Normally, it’s better to propagate the occurrence of a cancelling event botton-up, that is, signaling the child process to make it finish and then return the control to the calling parent process. In the calling process the outcome of the child process can be evaluated.

But if you absolutely want to cancel processes you can use the deleteProcessInstance method from the Runtime service. The bad news is that you will need to query for the related processes because deleting in cascade is a low level operation that is not supported in the API.

As said, a bottom-up solution would be better, even if it takes querying for different subprocesses to detect where the (whole) process got stuck and direct the cancelling event towards the problematic instance.

Jorge Mora.