jBPM 6.1 cannot resume process
Asked Answered
S

1

0

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.

Sublet answered 4/12, 2014 at 20:13 Comment(0)
O
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());
Olindaolinde answered 6/12, 2014 at 5:32 Comment(2)
OK I'm not entirely sure from which context you are executing your code, but if you have a look at the code of org.jbpm.process.instance.command.ResumeProcessInstanceCommand in the jbpm-flow project you may get a better idea of what needs to be doneOlindaolinde
Is it possible to persist the global and local variables when the server is restarted in jBPM 6?Lexie

© 2022 - 2024 — McMap. All rights reserved.