[jboss-user] [jBPM] - Re: jBPM5 - How to abort a already running ProcessInstance?

scurvo do-not-reply at jboss.com
Tue Feb 14 11:03:17 EST 2012

scurvo [https://community.jboss.org/people/scurvo] created the discussion

"Re: jBPM5 - How to abort a already running ProcessInstance?"

To view the discussion, visit: https://community.jboss.org/message/716564#716564


The way I solved it and according to my problem was:

1 - Create a Work Item handler and the work item with abort methods:

public class PrintWorkItemHandler extends MyWorkItemHandler {
    public Printer2 p;
    protected Date startTime;
    protected Date endTime;

    class printThread extends Thread {

        protected long wiID;

        public printThread(long wiID) {
            this.wiID = wiID;

        public void run() {
            startTime = new Date();
            p = new Printer2();

            // notify manager that work item has been completed
            mng.completeWorkItem(wiID, null);
            endTime = new Date();
            System.out.println("PRINT ENDED and took  " +
                            JBPMUtil.dateDiff(startTime, endTime));

    public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {

        new printThread(workItem.getId()).start();

    public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {
        p.stop = true;

2 - When i want a workItem to finish i do: 

mng.completeWorkItem(wiID, null); to complete ir
manager.abortWorkItem(workItem.getId()); to abort it

Reply to this message by going to Community

Start a new discussion in jBPM at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120214/b5b1057c/attachment.html 

More information about the jboss-user mailing list