ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
ReceiveTaskHandler receiveTaskHandler = new ReceiveTaskHandler(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler);
// Yes
ProcessInstance processInstance = ksession.startProcess("com.sample.test");
assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);
ksession = restoreSession(ksession, true);
ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
receiveTaskHandler.setKnowledgeRuntime(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler);
receiveTaskHandler.messageReceived("YesMessage", "YesValue");
assertProcessInstanceCompleted(processInstance.getId(), ksession);
receiveTaskHandler.messageReceived("NoMessage", "NoValue");
ksession = restoreSession(ksession, true);
ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
receiveTaskHandler.setKnowledgeRuntime(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler);
// No
processInstance = ksession.startProcess("com.sample.test");
receiveTaskHandler.messageReceived("NoMessage", "NoValue");
assertProcessInstanceCompleted(processInstance.getId(), ksession);
receiveTaskHandler.messageReceived("YesMessage", "YesValue");
}