Affan Dar [
https://community.jboss.org/people/affandar] created the discussion
"Re: How to get current node instance in a workitem handler?"
To view the discussion, visit:
https://community.jboss.org/message/730621#730621
--------------------------------------------------------------
I had to store the ksession id and the process instances it is running separately for
recovery. On server restart, I load all sessions and for all process instances stored in
my session->processinstanceid mapping table I call
ksession.getProcessInstance(processinstanceid).
From another thread here:
https://community.jboss.org/thread/195459
https://community.jboss.org/thread/195459, it seems like it should be possible to load a
process instance into a ksession different from the one it was created in (with some
caveats) but I didn't go that route.
Once the right ksession is loaded and available to the workitemhandler, finding the nodeId
is straightfoward. E.g. something like this:
private WorkItemNodeInstance getCurrentWorkItemNodeInstance(WorkItem workItem) {
RuleFlowProcessInstance processInst =
(RuleFlowProcessInstance)this.ksession.getProcessInstance(workItem.getProcessInstanceId());
Collection<NodeInstance> nodeInstances = processInst.getNodeInstances();
for(NodeInstance nodeInst : nodeInstances) {
if(nodeInst instanceof WorkItemNodeInstance) {
if(((WorkItemNodeInstance)nodeInst).getWorkItem().getId() ==
workItem.getId()) {
return ((WorkItemNodeInstance)nodeInst);
}
}
}
return null;
}
HTH
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/730621#730621]
Start a new discussion in jBPM at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]