How can I terminate a process instance that could either be sitting in an Human Interactive or a Timer activity.
TaskService is one solution but I don't want to take that route to achieve this simple requirement. Is there any recommended pattern to implement this.
I also thought of an event boundary with interuupting event, but not sure what to write there..
It was easy in Oracle BPm 10G where you could have a Notification Wait with interrupt and that is attached to an "Automatic" activity where we could say:
1. Terminate means you want to End that Process no matter where it is at any instance of time. Say if I have BPM Process with 10 SwimLanes it can be at any of the Lanes with any User. I am taking simple Example with Human Tasks, but you can apply for other component like Timer servces etc.
2. I hope you are aware of 2 things specially for Human Tasks: Action named "Withdraw" and a role named "Process Owner". For any human task, under Actions menu you should See a Withdraw option. You can code your application to capture this output using XOR gateway and if outcome is "WITHDRAW" directly end the process and go to End Node. If you have many places like this, there is easy way instead of running wires eveywhere. Create a simple throw even that goes to End Node. And after each human task check outcome if Withdraw, that that error, which will end the process. I hope you got the point.
b) The reason I mentioned Process Owner is, generally I do NOT give Withdraw control to each User who can work on any Task. If accidentally that User do this action, thats it. The process ENDS and you can never retriive it back. So under .TASK file, I preven Withdraw action to Asssignee and Instead give this action only to OWNER (Process Owner). Process owner is like admin who can pretty much see any tasks and I would give him all the permissions like these Withdraw, Reassing, Suspend etc etc. This gives more controlled power to your application. Anyhow, in bpm workspace, login as process owner and search for any Task aged for long time and jus Withdraw it.
You can do all the above using APIs also as far as you have Withdraw action going to the End Node.
If your requirement is something else, ignore above notes. But still you can think along the above lines, if all you want is to Kill a Running Process anytime.
As you know, in Oracle BPM 10g Message Wait with an Interrupt feature let us send a notification to a specific work item instance in the process either from another process or using the API. Once notified, we could abort the instance in the process it was interrupted from by setting the "action" predefined variable to ABORT.
In Oracle BPM 11g the equivalent is to add an Event Subprocess in your process. The steps to getting this functionality working in 11g are similar to what you did in 10g. Here's a high level summary of what you'll need to do:
1. Create a correlation in the process.
2. Initiate the correlation.
3. Add an event subprocess in the process.
4. Make sure that the event subprocess's start event is a Message Start Event and check its "Interrupting Event" checkbox.
5. Set the Message Start Event to use the correlation.
Hope this helps get you going,
I get your point on the 'event subprocess' i.e initiate the correlation and use the correlation and "interrupting" checkbox.
But what do I write in the Event subproces to move the instance to end. Are you implying that event subprocess will only have message start event going straight to message end event and this will move the instance to end.
So if my process instance was waiting in a timer, that timer would automatically get aborted as part of the message start event-->message end event transition defined in the event subprocess.