[jboss-user] [jBPM] - JBPM 5.3 Transactional persistence timing issue

Travers Snyman do-not-reply at jboss.com
Fri Feb 15 04:48:00 EST 2013


Travers Snyman [https://community.jboss.org/people/tsnyman] created the discussion

"JBPM 5.3 Transactional persistence timing issue"

To view the discussion, visit: https://community.jboss.org/message/797838#797838

--------------------------------------------------------------
We have come accross a transactional timing issue using JPBM5.3 as workflow. A simplified use case is as follows:

An external process is kicked off in a workItem handler in this case putting a message on a JMS queue. This could be from a human task. After this , the work item is completed  manager.completeWorkItem(workItem.getId(), results);

A reply message is then received on a JMS queue (external process) and and a catch event with signal definition is signalled that the message is received and the catch event signal needs to transition to the next node in the workflow. The signalling after the jms message is received happens as below:

  Collection<NodeInstance> nodeInstances = ((WorkflowProcessInstance)processInstance).getNodeInstances();
  if (nodeInstances.size() > 0) {
          NodeInstance nodeInstance = nodeInstances.iterator().next();
         processInstance.signalEvent(nodeName, success);

   }


The problem I am facing is that it seems there is a timing problem when the catch event is signalled while the workitem is still being completed (persisted). JBPM throws a null pointer exception and chasing the stack traces indicate that the 
kruntime is null. Following is the stack trace
java.lang.NullPointerException
    at org.jbpm.process.instance.impl.ProcessInstanceImpl.getProcess(ProcessInstanceImpl.java:68)
    at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.getWorkflowProcess(WorkflowProcessInstanceImpl.java:181)
    at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.getNodeContainer(WorkflowProcessInstanceImpl.java:69)
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.getNode(NodeInstanceImpl.java:103)
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.getNodeName(NodeInstanceImpl.java:79)
    at org.jbpm.workflow.instance.WorkflowRuntimeException.<init>(WorkflowRuntimeException.java:33)
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:132)

The nullpointer exception then causes a transaction rollback as expected

In ProcessInstanceImpl.java line 68, kruntime is null in the getProcess method

 public Process getProcess() {
        if (this.process == null) {
            this.process = kruntime.getKnowledgeBase().getProcess(processId);
        }
        return this.process;
    }

When a thread.sleep(2000) is inserted before the catch event is signalled, kruntime in the above code is not null and the workflow continues properly. This is what is leading me to believe it is a timing issue on the persistence side of completing the workitem.

Ideally I would have liked to have some inspection of the status of the workitem and then wait in a controlled manner for the actual completion of the workitem before the catch event is signalled, but it does not seem that something like that is available in the API. 

Does anyone have any suggestions on how to overcome this other than having an arbitry delay before signalling the catch event.

I am using Bitronix as the JTA transaction manager and am using Spring and Hibernate.
--------------------------------------------------------------

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

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130215/1c6ed27f/attachment.html 


More information about the jboss-user mailing list