I've made an all-in-one unit test to demo this problem.
The basic idea behind is during the execution of one process instance, each
node shall be active before being signaled and inactive after. The code will
print out all remaining active activities.
But after signaling B.1.1, the resulting output is
anonymous wrote : After signaling B.1.1, actives are [B.1.1, B.1.2, B.1.1.1,
B.2]
which is clearly not desirable, and the program broke afterwards.
package org.jbpm.examples.concurrency.graphbased;
| import java.util.ArrayList;
| import java.util.List;
| import org.jbpm.api.Execution;
| import org.jbpm.api.ProcessInstance;
| import org.jbpm.test.JbpmTestCase;
|
| public class ForkTest extends JbpmTestCase {
| String deployID = null;
| private String processDefinitionKey = "TestFork";
|
| private String getJPDL(){
| String jpdl = String.format(
| "<process name='%s' xmlns='http://jbpm.org/4.0/jpdl'>"
| +""
| +"<start g='211,16,92,52'>"
| +"<transition name='to A' to='A' g='-31,-22'/>"
| +"</start>"
| +""
| +"<end g='172,848,48,48' name='end'/>"
| +"<state name='A' g='211,100,92,52'>"
| +"<transition name='to B' to='B' g='-31,-22'/>"
| +"</state>"
| +"<state name='B' g='211,184,92,52'>"
| +"<transition name='to fork1' to='fork1'
g='-56,-22'/>"
| +"</state>"
| +"<fork name='fork1' g='233,268,48,48'>"
| +"<transition name='to B.1' to='B.1' g='-43,-22'/>"
| +"<transition name='to B.2' to='B.2' g='-43,-22'/>"
| +"</fork>"
| +"<state name='B.1' g='149,348,92,52'>"
| +"<transition name='to fork2' to='fork2'
g='-56,-22'/>"
| +"</state>"
| +"<state name='B.2' g='273,348,92,52'>"
| +"<transition name='to B.2.1' to='B.2.1'
g='-63,-22'/>"
| +"</state>"
| +"<fork name='fork2' g='140,432,92,52'>"
| +"<transition name='to B.1.1' to='B.1.1'
g='-55,-22'/>"
| +"<transition name='to B.1.2' to='B.1.2'
g='-55,-22'/>"
| +"</fork>"
| +"<state name='B.1.1' g='16,516,92,52'>"
| +"<transition name='to B.1.1.1' to='B.1.1.1'
g='-63,-22'/>"
| +"</state>"
| +"<state name='B.1.2' g='140,516,92,52'>"
| +"<transition name='to fork3' to='fork3'
g='-56,-22'/>"
| +"</state>"
| +"<fork name='fork3' g='140,600,92,52'>"
| +"<transition name='to B.1.2.1' to='B.1.2.1'
g='-67,-22'/>"
| +"<transition name='to B.1.2.2' to='B.1.2.2'
g='-67,-22'/>"
| +"</fork>"
| +"<state name='B.1.2.1' g='89,684,92,52'>"
| +"<transition name='to join1' to='join1'
g='-54,-22'/>"
| +"</state>"
| +"<state name='B.1.2.2' g='213,684,92,52'>"
| +"<transition name='to join1' to='join1'
g='-54,-22'/>"
| +"</state>"
| +"<join name='join1' g='172,768,48,48'>"
| +"<transition name='to end' to='end' g='-46,-22'/>"
| +"</join>"
| +"<state name='B.1.1.1' g='16,600,92,52'>"
| +"<transition name='to join1' to='join1'
g='90,771:-54,-22'/>"
| +"</state>"
| +"<state name='B.2.1' g='279,432,92,52'>"
| +"<transition name='to B.2.1.1' to='B.2.1.1'
g='-63,-22'/>"
| +"</state>"
| +"<state name='B.2.1.1' g='285,516,92,52'>"
| +"<transition name='to join1' to='join1'
g='354,801:-54,-22'/>"
| +"</state>"
| +""
| +"</process>", processDefinitionKey);
|
| return jpdl;
| }
|
| protected void setUp() throws Exception {
| super.setUp();
| String jpdl = getJPDL();
| deployID =
repositoryService.createDeployment().addResourceFromString("test_fork.jpdl.xml",
jpdl).deploy();
| }
|
| protected void tearDown() throws Exception {
| repositoryService.deleteDeployment(deployID);
|
| super.tearDown();
| }
|
| public void testConcurrencyGraphBased() {
| ProcessInstance processInstance =
executionService.startProcessInstanceByKey(processDefinitionKey);
| List<String> path = new ArrayList<String>();
| path.add("A");
| path.add("B");
| path.add("B.1");
| path.add("B.1.1");
| path.add("B.1.1.1");
| path.add("B.1.2");
| path.add("B.1.2.1");
| path.add("B.1.2.2");
|
| for (String activityName : path){
|
assertNotNull(processInstance.findActiveExecutionIn(activityName));
| Execution execution =
processInstance.findActiveExecutionIn(activityName);
| processInstance =
executionService.signalExecutionById(execution.getId());
| System.out.println(String.format("After signaling %s, actives
are %s", activityName, processInstance.findActiveActivityNames()));
| assertNull(processInstance.findActiveExecutionIn(activityName));
| }
| }
| }
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4255354#4255354
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4255354
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user