JBoss Community

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

created by leo li in jBPM Development - View the full discussion

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  TYPE  NODEINSTANCEID  NODEID  PROCESSINSTANCEID  PROCESSID  LOG_DATE  NODENAME 
683059134LeadProcess2011-11-28 12:44:43.048Qualified
682148134LeadProcess2011-11-28 12:44:43.048Gateway
681048134LeadProcess2011-11-28 12:44:43.048Gateway
680135134LeadProcess2011-11-28 12:44:43.033Pending
679035134LeadProcess2011-11-28 12:44:36.36Pending



SELECT * FROM PROCESSINSTANCEINFO where iNSTANCEID =134;

 

INSTANCEID  LASTMODIFICATIONDATE  LASTREADDATE  PROCESSID  PROCESSINSTANCEBYTEARRAY  STARTDATE  STATE  OPTLOCK 
1342011-11-28 12:44:36.3762011-11-28 12:57:39.437LeadProcessaced00057765000852756c65466c6f770000000000000086000b4c65616450726f6365737300000001000000000000000400000000001200000000000000030000000000000005001b00000000000000fd00000000000100000000000000020006616374696f6e0000000074000750656e64696e67770c0006757365724964000000007400056b72697376


 

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

Start a new discussion in jBPM Development at Community