[jboss-dev-forums] [jBPM Development] - [jbpm5.1]Can get the current nodeId, correctly??

leo li do-not-reply at jboss.com
Mon Nov 28 10:59:17 EST 2011


leo li [http://community.jboss.org/people/leo87601] created the discussion

"[jbpm5.1]Can get the current nodeId,correctly??"

To view the discussion, visit: http://community.jboss.org/message/638682#638682

--------------------------------------------------------------
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;

|| ID   (http://localhost:8082/query.do?jsessionid=eba938cf1dbf38d4a410125bbe377788#) || TYPE   (http://localhost:8082/query.do?jsessionid=eba938cf1dbf38d4a410125bbe377788#) || NODEINSTANCEID   (http://localhost:8082/query.do?jsessionid=eba938cf1dbf38d4a410125bbe377788#) || NODEID   (http://localhost:8082/query.do?jsessionid=eba938cf1dbf38d4a410125bbe377788#) || PROCESSINSTANCEID   (http://localhost:8082/query.do?jsessionid=eba938cf1dbf38d4a410125bbe377788#) || PROCESSID   (http://localhost:8082/query.do?jsessionid=eba938cf1dbf38d4a410125bbe377788#) || LOG_DATE   (http://localhost:8082/query.do?jsessionid=eba938cf1dbf38d4a410125bbe377788#) || NODENAME   (http://localhost:8082/query.do?jsessionid=eba938cf1dbf38d4a410125bbe377788#) ||
| 683 | 0 | 5 | 9 | 134 | LeadProcess | 2011-11-28 12:44:43.048 | Qualified |
| 682 | 1 | 4 | 8 | 134 | LeadProcess | 2011-11-28 12:44:43.048 | Gateway |
| 681 | 0 | 4 | 8 | 134 | LeadProcess | 2011-11-28 12:44:43.048 | Gateway |
| 680 | 1 | 3 | 5 | 134 | LeadProcess | 2011-11-28 12:44:43.033 | Pending |
| 679 | 0 | 3 | 5 | 134 | LeadProcess | 2011-11-28 12:44:36.36 | Pending |



SELECT * FROM PROCESSINSTANCEINFO where iNSTANCEID =134;

|| INSTANCEID   (http://localhost:8082/query.do?jsessionid=eba938cf1dbf38d4a410125bbe377788#) || LASTMODIFICATIONDATE   (http://localhost:8082/query.do?jsessionid=eba938cf1dbf38d4a410125bbe377788#) || LASTREADDATE   (http://localhost:8082/query.do?jsessionid=eba938cf1dbf38d4a410125bbe377788#) || PROCESSID   (http://localhost:8082/query.do?jsessionid=eba938cf1dbf38d4a410125bbe377788#) || PROCESSINSTANCEBYTEARRAY   (http://localhost:8082/query.do?jsessionid=eba938cf1dbf38d4a410125bbe377788#) || STARTDATE   (http://localhost:8082/query.do?jsessionid=eba938cf1dbf38d4a410125bbe377788#) || STATE   (http://localhost:8082/query.do?jsessionid=eba938cf1dbf38d4a410125bbe377788#) || OPTLOCK   (http://localhost:8082/query.do?jsessionid=eba938cf1dbf38d4a410125bbe377788#) ||
| 134 | 2011-11-28 12:44:36.376 | 2011-11-28 12:57:39.437 | LeadProcess | aced00057765000852756c65466c6f770000000000000086000b4c65616450726f6365737300000001000000000000000400000000001200000000000000030000000000000005001b00000000000000fd00000000000100000000000000020006616374696f6e0000000074000750656e64696e67770c0006757365724964000000007400056b72697376 |



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.
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/638682#638682]

Start a new discussion in jBPM Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2035]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20111128/16f1a0df/attachment.html 


More information about the jboss-dev-forums mailing list