[jboss-user] [jBPM Users] - Re: workflow design about wait states
mmusaji
do-not-reply at jboss.com
Mon Sep 14 09:00:58 EDT 2009
Thanks for that Ronald, be a huge help if you can see what I'm doing wrong.
So I changed the async nodes (custom one and two) to takeDefaultTransition().
| package org.workflow.test.forum;
|
| import java.util.List;
| import java.util.Map;
|
| import org.jbpm.api.Execution;
| import org.jbpm.api.ProcessInstance;
| import org.jbpm.api.activity.ActivityExecution;
| import org.jbpm.api.activity.ExternalActivityBehaviour;
| import org.jbpm.api.job.Job;
| import org.jbpm.test.JbpmTestCase;
|
| public class ProcessTest extends JbpmTestCase {
| String deploymentDbid;
|
| protected void setUp() throws Exception {
| super.setUp();
| deploymentDbid = repositoryService.createDeployment()
| .addResourceFromClasspath("org/workflow/test/forum/process.jpdl.xml")
| .deploy();
| }
|
| protected void tearDown() throws Exception {
| repositoryService.deleteDeploymentCascade(deploymentDbid);
| super.tearDown();
| }
|
| public void testProcess() throws Exception {
| ProcessInstance processInstance = executionService.startProcessInstanceByKey("process");
| Execution executionInOne = processInstance.findActiveExecutionIn("custom one");
| assertNotNull(executionInOne);
| processInstance = executionService.signalExecutionById(executionInOne.getId());
|
| String processInstanceId = processInstance.getId();
|
| List<Job> jobs = managementService.createJobQuery()
| .processInstanceId(processInstanceId)
| .list();
|
| assertEquals(2, jobs.size());
|
| Job job = jobs.get(0);
|
| managementService.executeJob(job.getId());
|
| job = jobs.get(1);
|
| managementService.executeJob(job.getId());
|
| Execution executionInFour = processInstance.findActiveExecutionIn("custom four");
| assertNotNull(executionInFour);
| processInstance = executionService.signalExecutionById(executionInFour.getId());
| }
|
| public static class CustomOne implements ExternalActivityBehaviour {
| private static final long serialVersionUID = 1L;
|
| public void execute(ActivityExecution execution) throws Exception {
| System.out.println("Executing");
|
| System.out.println(execution.getActivityName());
|
| execution.waitForSignal();
| }
|
| public void signal(ActivityExecution execution,
| String signalName,
| Map<String, ?> parameters) {
| execution.take(signalName);
| }
| }
|
| public static class CustomTwo implements ExternalActivityBehaviour {
| private static final long serialVersionUID = 1L;
|
| public void execute(ActivityExecution execution) throws Exception {
| System.out.println("Executing");
|
| System.out.println(execution.getActivityName());
|
| execution.takeDefaultTransition();
| }
|
| public void signal(ActivityExecution execution,
| String signalName,
| Map<String, ?> parameters) {
| execution.take(signalName);
| }
| }
|
| public static class CustomThree implements ExternalActivityBehaviour {
| private static final long serialVersionUID = 1L;
|
| public void execute(ActivityExecution execution) throws Exception {
| System.out.println("Executing");
|
| System.out.println(execution.getActivityName());
|
| execution.takeDefaultTransition();
| }
|
| public void signal(ActivityExecution execution,
| String signalName,
| Map<String, ?> parameters) {
| execution.take(signalName);
| }
| }
|
| public static class CustomFour implements ExternalActivityBehaviour {
| private static final long serialVersionUID = 1L;
|
| public void execute(ActivityExecution execution) throws Exception {
| System.out.println("Executing");
|
| System.out.println(execution.getActivityName());
|
| execution.waitForSignal();
| }
|
| public void signal(ActivityExecution execution,
| String signalName,
| Map<String, ?> parameters) {
| execution.take(signalName);
| }
| }
|
| }
|
|
With the same workflow as before I get custom four node as showing output but still get null when the unittest attempts to find execution in this node.
| 13:58:02,975 FIN | [BaseJbpmTestCase] === starting testProcess =============================
| 13:58:03,100 FIN | [BaseJbpmTestCase] using ProcessEngine 22743805
| log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
| log4j:WARN Please initialize the log4j system properly.
| 13:58:04,288 FIN | [ProcessDefinitionImpl] creating new execution for process 'process'
| 13:58:04,288 FIN | [DefaultIdGenerator] generated execution id process.222
| Executing
| custom one
| 13:58:04,288 FIN | [ExecuteActivity] executing activity(14731203)
| 13:58:04,288 FIN | [ExecuteActivity] executing activity(custom one)
| 13:58:04,303 FIN | [Signal] signalling activity(custom one), signalName=null
| 13:58:04,303 FIN | [ExecuteActivity] executing activity(fork)
| 13:58:04,303 FIN | [DefaultIdGenerator] generated execution id process.222.custom two
| 13:58:04,303 FIN | [ExecutionImpl] created execution[process.222.custom two]
| 13:58:04,319 FIN | [JobExecutorMessageSession] sending message ExecuteActivityMessage
| 13:58:04,319 INF | [JobExecutorThread] starting...
| 13:58:04,319 INF | [JobExecutorThread] starting...
| 13:58:04,319 INF | [JobExecutorThread] starting...
| 13:58:04,319 INF | [DispatcherThread] starting...
| 13:58:04,319 FIN | [DefaultIdGenerator] generated execution id process.222.custom three
| 13:58:04,319 FIN | [ExecutionImpl] created execution[process.222.custom three]
| 13:58:04,319 FIN | [JobExecutorMessageSession] sending message ExecuteActivityMessage
| 13:58:04,319 FIN | [AcquireJobsCmd] start querying first acquirable job...
| 13:58:04,319 FIN | [AcquireJobsCmd] locking jobs []
| 13:58:04,319 FIN | [GetNextDueDateCmd] getting next due date...
| 13:58:04,319 FIN | [GetNextDueDateCmd] next due date is null
| 13:58:04,319 FIN | [DispatcherThread] DispatcherThread will wait for max 600ms on org.jbpm.pvm.internal.jobexecutor.JobExecutor at 1ff2e1b
| 13:58:04,319 FIN | [DispatcherThread] DispatcherThread woke up
| 13:58:04,335 FIN | [AcquireJobsCmd] start querying first acquirable job...
| 13:58:04,335 FIN | [AcquireJobsCmd] locking jobs [296]
| 13:58:04,335 FIN | [DispatcherThread] pushing jobs on the queue [296]
| 13:58:04,335 FIN | [DispatcherThread] added jobs [296] to the queue
| 13:58:04,335 FIN | [AcquireJobsCmd] start querying first acquirable job...
| 13:58:04,335 FIN | [AcquireJobsCmd] locking jobs [297]
| 13:58:04,335 FIN | [ExecuteJobCmd] executing job ExecuteActivityMessage[296]...
| 13:58:04,335 FIN | [JobExecutorThread] took job(s) [296] from queue
| 13:58:04,335 FIN | [DispatcherThread] pushing jobs on the queue [297]
| 13:58:04,335 FIN | [DispatcherThread] added jobs [297] to the queue
| 13:58:04,335 FIN | [AcquireJobsCmd] start querying first acquirable job...
| 13:58:04,350 FIN | [AcquireJobsCmd] locking jobs []
| 13:58:04,350 FIN | [GetNextDueDateCmd] getting next due date...
| 13:58:04,350 FIN | [GetNextDueDateCmd] next due date is null
| 13:58:04,350 FIN | [DispatcherThread] DispatcherThread will wait for max 600ms on org.jbpm.pvm.internal.jobexecutor.JobExecutor at 1ff2e1b
| Executing
| custom two
| 13:58:04,350 FIN | [ExecuteActivity] execution[process.222.custom two] executes activity(custom two)
| 13:58:04,350 FIN | [JobExecutorThread] took job(s) [297] from queue
| 13:58:04,350 FIN | [JobExecutorMessageSession] sending message ExecuteActivityMessage
| 13:58:04,350 FIN | [ExecuteJobCmd] executing job ExecuteActivityMessage[297]...
| Executing
| custom three
| 13:58:04,350 FIN | [ExecuteJobCmd] executed job ExecuteActivityMessage[296]
| 13:58:04,366 FIN | [ExecuteActivity] execution[process.222.custom three] executes activity(custom three)
| 13:58:04,366 FIN | [JobExecutorMessageSession] sending message ExecuteActivityMessage
| 13:58:04,366 FIN | [ExecuteJobCmd] executed job ExecuteActivityMessage[297]
| 13:58:04,366 FIN | [ExecuteJobCmd] executing job ExecuteActivityMessage[297]...
| 13:58:04,366 FIN | [ExecuteJobCmd] job 296 no longer exists
| Executing
| custom three
| 13:58:04,366 FIN | [DispatcherThread] DispatcherThread woke up
| 13:58:04,366 FIN | [AcquireJobsCmd] start querying first acquirable job...
| 13:58:04,366 FIN | [ExecuteActivity] execution[process.222.custom three] executes activity(custom three)
| 13:58:04,366 FIN | [JobExecutorMessageSession] sending message ExecuteActivityMessage
| 13:58:04,366 FIN | [ExecuteJobCmd] executed job ExecuteActivityMessage[297]
| 13:58:04,381 FIN | [AcquireJobsCmd] locking jobs [298, 299]
| 13:58:04,381 FIN | [DispatcherThread] pushing jobs on the queue [298, 299]
| 13:58:04,381 FIN | [DispatcherThread] added jobs [298, 299] to the queue
| 13:58:04,381 FIN | [JobExecutorThread] took job(s) [298, 299] from queue
| 13:58:04,381 FIN | [AcquireJobsCmd] start querying first acquirable job...
| 13:58:04,381 FIN | [AcquireJobsCmd] locking jobs []
| 13:58:04,381 FIN | [GetNextDueDateCmd] getting next due date...
| 13:58:04,381 FIN | [ExecuteJobCmd] executing job ExecuteActivityMessage[298]...
| 13:58:04,381 FIN | [GetNextDueDateCmd] next due date is null
| 13:58:04,381 FIN | [DispatcherThread] DispatcherThread will wait for max 600ms on org.jbpm.pvm.internal.jobexecutor.JobExecutor at 1ff2e1b
| 13:58:04,381 FIN | [ExecuteActivity] execution[process.222.custom two] executes activity(join)
| 13:58:04,381 FIN | [ExecuteJobCmd] executed job ExecuteActivityMessage[298]
| 13:58:04,381 FIN | [ExecuteJobCmd] executing job ExecuteActivityMessage[299]...
| 13:58:04,397 FIN | [ExecuteActivity] execution[process.222.custom three] executes activity(join)
| 13:58:04,397 FIN | [ExecutionImpl] execution[process.222.custom two] ends
| 13:58:04,397 FIN | [ExecutionImpl] execution[process.222.custom three] ends
| 13:58:04,397 FIN | [ExecuteActivity] executing activity(custom four)
| Executing
| custom four
| 13:58:04,397 FIN | [ExecuteJobCmd] executed job ExecuteActivityMessage[299]
| 13:58:04,428 FIN | [ExecuteJobCmd] job 297 no longer exists
| 13:58:04,428 SEV | [BaseJbpmTestCase]
| ### EXCEPTION ###########################################
| 13:58:04,428 SEV | [BaseJbpmTestCase] ASSERTION FAILURE: null
| junit.framework.AssertionFailedError
| at junit.framework.Assert.fail(Assert.java:47)
| at junit.framework.Assert.assertTrue(Assert.java:20)
| at junit.framework.Assert.assertNotNull(Assert.java:220)
| at junit.framework.Assert.assertNotNull(Assert.java:213)
| at org.workflow.test.forum.ProcessTest.testProcess(ProcessTest.java:51)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:597)
| at junit.framework.TestCase.runTest(TestCase.java:154)
| at org.jbpm.test.BaseJbpmTestCase.runTest(BaseJbpmTestCase.java:80)
| at junit.framework.TestCase.runBare(TestCase.java:127)
| at junit.framework.TestResult$1.protect(TestResult.java:106)
| at junit.framework.TestResult.runProtected(TestResult.java:124)
| at junit.framework.TestResult.run(TestResult.java:109)
| at junit.framework.TestCase.run(TestCase.java:118)
| at junit.framework.TestSuite.runTest(TestSuite.java:208)
| at junit.framework.TestSuite.run(TestSuite.java:203)
| at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
| at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
| at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
| at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
| at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
| at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
| ### EXCEPTION ###########################################
| 13:58:04,428 SEV | [BaseJbpmTestCase]
| 13:58:04,444 FIN | [DbSessionImpl] deleting history process instance process.222
| 13:58:04,460 FIN | [DbSessionImpl] deleting process instance process.222
| 13:58:04,460 FIN | [DeleteDeploymentCmd] deleting deployment 109
| 13:58:04,475 FIN | [BaseJbpmTestCase] === ending testProcess =============================
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4255090#4255090
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4255090
More information about the jboss-user
mailing list