[jbpm-commits] JBoss JBPM SVN: r4860 - in jbpm4/trunk/modules: examples/src/test/resources/org/jbpm/examples/async/activity and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed May 20 12:10:21 EDT 2009
Author: tom.baeyens at jboss.com
Date: 2009-05-20 12:10:21 -0400 (Wed, 20 May 2009)
New Revision: 4860
Modified:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/activity/AsyncActivityTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.jpdl.xml
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml
Log:
JBPM-2256 starting async continuations docs
Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/activity/AsyncActivityTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/activity/AsyncActivityTest.java 2009-05-20 14:07:38 UTC (rev 4859)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/activity/AsyncActivityTest.java 2009-05-20 16:10:21 UTC (rev 4860)
@@ -22,6 +22,8 @@
package org.jbpm.examples.async.activity;
import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
import org.jbpm.test.JbpmTestCase;
@@ -47,7 +49,37 @@
}
public void testJavaInstantiate() {
- Execution execution = executionService.startProcessInstanceByKey("AsyncActivity");
- String executionId = execution.getId();
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncActivity");
+ String processInstanceId = processInstance.getId();
+
+ assertEquals(Execution.STATE_ASYNC, processInstance.getState());
+ assertEquals("generate pdf", processInstance.getActivityName());
+
+ Job job = managementService.createJobQuery()
+ .processInstanceId(processInstanceId)
+ .uniqueResult();
+ managementService.executeJob(job.getDbid());
+
+ processInstance = executionService.findProcessInstanceById(processInstanceId);
+
+ assertEquals(Execution.STATE_ASYNC, processInstance.getState());
+ assertEquals("calculate primes", processInstance.getActivityName());
+
+ job = managementService.createJobQuery()
+ .processInstanceId(processInstanceId)
+ .uniqueResult();
+ managementService.executeJob(job.getDbid());
+
+ processInstance = executionService.findProcessInstanceById(processInstanceId);
+
+ assertEquals(Execution.STATE_ASYNC, processInstance.getState());
+ assertEquals("run test suite", processInstance.getActivityName());
+
+ job = managementService.createJobQuery()
+ .processInstanceId(processInstanceId)
+ .uniqueResult();
+ managementService.executeJob(job.getDbid());
+
+ assertNull(executionService.findProcessInstanceById(processInstanceId));
}
}
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.jpdl.xml 2009-05-20 14:07:38 UTC (rev 4859)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.jpdl.xml 2009-05-20 16:10:21 UTC (rev 4860)
@@ -1,32 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
-<process name="AsyncActivity" xmlns="http://jbpm.org/4.0/jpdl">
-
- <start>
- <transition to="generate pdf" />
- </start>
-
+<process name="AsyncActivity" xmlns="http://jbpm.org/4.0/jpdl">
+
+ <start g="14,28,80,40">
+ <transition to="generate pdf"/>
+ </start>
+
<java name="generate pdf"
+ continue="async"
class="org.jbpm.examples.async.activity.Application"
- method="generatePdf"
- continue="async">
- <transition to="calculate primes" />
- </java>
-
+ method="generatePdf"
+ g="86,26,87,50">
+ <transition to="calculate primes"/>
+ </java>
+
<java name="calculate primes"
+ continue="async"
class="org.jbpm.examples.async.activity.Application"
- method="calculatePrimes"
- continue="async">
- <transition to="run test suite" />
- </java>
-
+ method="calculatePrimes"
+ g="203,26,98,50">
+ <transition to="run test suite"/>
+ </java>
+
<java name="run test suite"
+ continue="async"
class="org.jbpm.examples.async.activity.Application"
- method="runTestSuite"
- continue="async">
- <transition to="end" />
- </java>
-
- <end name="end" />
-
+ method="runTestSuite"
+ g="330,26,96,50">
+ <transition to="end"/>
+ </java>
+
+ <end name="end" g="452,28,80,40"/>
+
</process>
\ No newline at end of file
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml 2009-05-20 14:07:38 UTC (rev 4859)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml 2009-05-20 16:10:21 UTC (rev 4860)
@@ -2184,6 +2184,35 @@
event(end) on process(EventListener)]</programlisting>
</section>
+ <section id="asynchronouscontinuations">
+ <title>Asynchronous continuations</title>
+ <para>Each invocation of <literal>ExecutionService.startProcessInstanceById(...)</literal>
+ or <literal>ExecutionService.signalProcessInstanceById(...)</literal> will cause
+ the process to be executed in the thread of the client. In other words, those
+ methods will only return after the process execution has arrived in a wait state.
+ </para>
+ <para>This default behaviour has a couple of advantages: user application transactions
+ can be easily propagated to jBPM to that jBPM's DB updates are done in the user's
+ transaction context. Secondly, it's possible for a client to get an exception in
+ case something goes wrong during execution of the process. Usually, the automatic
+ work that has to be done as part of the process inbetween two wait states is
+ relatively small. E.g. < 1 second, even if multiple automatic activities
+ are executed inbetween 2 wait states. So in most situations, it's good to
+ do all that work in a single transaction. This explains that the default behaviour
+ of jPDL is to perform all work of the process synchronously in the thread of client.
+ </para>
+ <para>For those cases where it is needed, jPDL allows for very fine grained control over
+ transaction boundaries. On various places in the process, asynchronous continuations
+ can be introduced. Asynchronous continuations are placed on places where logically
+ the jBPM engine remains in control for executing a series of automatic steps.
+ </para>
+ <para>Upon an asynchronous continuation, an asynchronous message will be sent as
+ part of the currently ongoing transaction. And then originally invoked method
+ like e.g. <literal>startProcessInstanceById(...)</literal>
+ or <literal>signalProcessInstanceById(...)</literal> will return.
+ </para>
+ </section>
+
<section id="timer">
<title><literal>timer</literal> </title>
<para>A timer can be specified in the <literal>transition</literal>
More information about the jbpm-commits
mailing list