我们可以暂停像这样的流程实例:
org.jbpm.process.instance.ProcessInstance processInstance = //...;
processInstance.setState(STATE_SUSPENDED);
和恢复:
kieSession.getWorkItemManager().completeWorkItem(processInstance.getId(), params);
但它不起作用! ......问题是什么?
感谢。
答案 0 :(得分:1)
要恢复进程,请使用processInstance.setState(ProcessInstance.STATE_ACTIVE)。 WorkItemManager在workItems(Web服务调用,人工任务,客户处理程序等)上运行,而不是processInstances。
请尝试以下代码:
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());