问题
I'd like to implement the ability to terminate the process instance at any user task of my jbpm project. I know that I should theoretically be able to do this with a termination end event attached to any task in my workflow, but this seems like a bad solution to have so many terminate events.
Is there a better, more efficient, more readable way to do this?
回答1:
I don't know if this is better, but you can do this:
- model, in parallel, a intermediate catch signal followed by your terminate event
- use the space "On Exit Script" on Human Task to notify mentioned signal, using method signalEvent
kcontext.getProcessInstance().signalEvent("terminate",null);
where "terminate" is the signal's name catched by your Signal Event.
Here you can see a approach: http://s7.postimg.org/p6ktmvz0r/Screen_Shot_2015_01_18_at_19_45_48.png
回答2:
The app we ended up building used a custom front-end which interfaced with a JBPM service.
To terminate process at any step we recorded the master process instance ID in our own database when it was created. We then created a 'cancel project' function which recursively collected all process ids under a single master process id, and then terminated them via remote API, starting with the master process id.
Note that if you do this, you need to abort the list of process instances starting from the master process, and then work your way forward. If you don't, aborting child processes first can spawn more processes.
来源:https://stackoverflow.com/questions/27910474/terminate-process-at-any-step-jbpm