Dear all,
We want to get the current node name after completed a task.But it is not working correctly some time.
we found the error happen here.
long nodeId = wfInstance.getNodeInstances().iterator().next().getNodeId();
BTW, Before we setted the persistence, this issue does not happen.
The data seem had problem too, we found that the PROCESSINSTANCEINFO's lastmodificationdate(12:44:36) is the same as the pending node's log time, but the workflow had been run into Qualified at 12:44:43.
We can not see the processinstancebytearray, so not sure the processintanceinfo had been updated correctly or not?
select * from nodeinstancelog where processinstanceid =134 order by id desc;
SELECT * FROM PROCESSINSTANCEINFO where iNSTANCEID =134;
Environment : Jboss 5.1, h2 database, windows 2003. we are using the default setting of jbpm-5.1.0.Final-installer-full.zip
Here is our code of complete task.
public ProcessInstanceBO completeUserTask(long instanceId, String toState){
ProcessInstance instance = ksession.getProcessInstance(instanceId); // init process by instanceid
WorkflowProcessInstance wfInstance = ((WorkflowProcessInstance)instance);
// get currently Node instances
Iterator<NodeInstance> iterator = wfInstance.getNodeInstances().iterator();
NodeInstance nodeInstance = iterator.next();
// compelte workitem.
final long workItemId = workItemNodeInstance.getWorkItemId();
final Map<String, Object> results = new HashMap<String, Object>();
results.put(this.ACTION, toState);
ksession.getWorkItemManager().completeWorkItem(workItemId, results);
ksession.getWorkItemManager().abortWorkItem(workItemId);
// retrieve the process instance again.
instance = ksession.getProcessInstance(instanceId);
WorkflowProcessInstance wfInstance = (WorkflowProcessInstance) instance;
//retrieve the current node again. we expect that , here is the next step's nodeid, but it doesn't work correctly every time. some time it still in the last stage.
long nodeId = wfInstance.getNodeInstances().iterator().next().getNodeId();
logger.debug("Process current node id: " + nodeId );
WorkflowProcess wfProcess = (WorkflowProcess) readKnowledgeBase().getProcess(wfInstance.getProcessId());
//We cannot get the correct Node name because.
Node node = wfProcess.getNode(nodeId);
....
}
We are confusing on this issue, please help. Thanks a lots.