[jboss-user] [JBoss jBPM] - Re: Transaction demarcation, callculation of the next proces

asmo do-not-reply at jboss.com
Thu Jan 11 08:55:47 EST 2007


Thanks for the reply!

Here is my processdefinition.


  | <?xml version="1.0" encoding="UTF-8"?>
  | 
  | <process-definition
  |   xmlns="urn:jbpm.org:jpdl-3.1"
  |   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  |   xsi:schemaLocation="http://jbpm.org/3/jpdl http://jbpm.org/xsd/jpdl-3.1.xsd"
  |   name="test">
  |    <start-state name="start">
  |       <transition name="toFirstState" to="FirstState"></transition>
  |    </start-state>
  |    <state name="FirstState">
  |       <transition name="toNode" to="node1"></transition>
  | 
  |    </state>
  |    <end-state name="end1"></end-state>
  |    <node async="false" name="node1">
  |       	<action name="test" class="de.uniSiegen.crm.server.workflow.action.TestActivity" />
  |    
  |       <transition name="toSecondState" to="SecondState"></transition>
  |    </node>
  |    <state name="SecondState">
  |       <transition name="toEnd" to="end1"></transition>
  |    </state>
  | </process-definition>
  | 
  | 

And this is my actionhandler, which just should simulate a long process calculation. 

public class TestActivity implements ActionHandler {
  |     Logger logger = ServiceLocator.getLogger(WorkflowBean.class);
  |     public void execute(ExecutionContext arg0) throws Exception {
  |         // TODO Auto-generated method stub
  |         
  |         Node node =  arg0.getNode();
  |         node.leave(arg0);
  |         
  |         Object o = new Object();
  |         synchronized (o) {
  |             o.wait(10000);
  | 
  |         }
  |         logger.info("###########################################################################");
  |         logger.info("# TESTACTIVITY !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#");
  |         logger.info("###########################################################################");
  | 
  |     }
  | 
  | }


If behavior of the process without async = "true" is :

  | processinstance.signal("toNode");
  | 
after calling the signal, the client waits 10 seconds until the node has executed the action...
In the next step i ask the processinstance for the name of the actual node.

  | System.out.println("Node of the process :" + processinstance.getRootToken().getNode().getName() );
  | 
After waiting 10 seconds, the output ist : SecondState
So, the process has needed 10 seconds for the execution and automatically enter the SecondState.
That is exactly, what i have expected.

If i change the processdefinition for asynchron execution ( async = "true" ) the behavior is this:

processintance.signal("toNode");
the token enters the node.


System.out.println("Node of the process : " + processinstance.getRootToken().getNode().getName());
at once, without waiting 10 seconds for the execution of the node, the name of the node is released.
So, the client thread does not wait for the execution. 
But the output of the system.out is: node1
After reading this part of the documentation: 
anonymous wrote : 
  | Note that the jbpm client code can now commit the transaction. The sending of the message should be done in the same transaction as the process updates. So the net result of the transaction is that the token has moved to the next node (which has not yet been executed) and a org.jbpm.command.ExecuteNodeCommand-message has been sent on the asynchronous messaging system to the jBPM Command Executor.
i thought, that the processinstance should at once move to the SecondState, without waiting for the action of the node, and therefore i expected SecondState as output of the System.out.

My question:
Have i understood the documentation wrong and the output: node1
 is, right?
Or is there an error in my code and the actual node of the processinstance should be SecondState?

Thanks
asmo

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4000433#4000433

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4000433



More information about the jboss-user mailing list