[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

--------------------------------------------------------------
Hi, 

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();
            p.printAlot("adasd");


            // 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) {
        super.addWorkItem(workItem);
        super.setWorkItemManager(manager);


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


    public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {
        System.out.println("ABORTED");
        p.stop = true;
        manager.abortWorkItem(workItem.getId());
    }
}

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

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

Reply to this message by going to Community
[https://community.jboss.org/message/716564#716564]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- 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