问题
We can suspend a process instance like this :
org.jbpm.process.instance.ProcessInstance processInstance = //...;
processInstance.setState(STATE_SUSPENDED);
and to resume it :
kieSession.getWorkItemManager().completeWorkItem(processInstance.getId(), params);
but it doesn't work! ... what is the problem?
Thanks.
回答1:
To resume a process, use processInstance.setState( ProcessInstance.STATE_ACTIVE ). The WorkItemManager operates on workItems (web service calls, human tasks, customer handlers etc.) rather than processInstances.
Try the following code:
KieSession ksession=......
ProcessInstance processInstance = ksession.startProcess(......
//suspend:
SuspendProcessInstanceCommand susp=new SuspendProcessInstanceCommand();
susp.setProcessInstanceId(processInstance.getId());
ksession.execute(susp);
//confirm suspended:
assertEquals(ProcessInstance.STATE_SUSPENDED, ksession.getProcessInstance(processInstance.getId()).getState());
//resume:
ResumeProcessInstanceCommand res=new ResumeProcessInstanceCommand();
res.setProcessInstanceId(processInstance.getId());
ksession.execute(res);
//confirm active:
assertEquals(ProcessInstance.STATE_ACTIVE, ksession.getProcessInstance(processInstance.getId()).getState());
来源:https://stackoverflow.com/questions/27303161/jbpm-6-1-cannot-resume-process