[jbpm-commits] JBoss JBPM SVN: r4861 - 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 15:20:08 EDT 2009


Author: tom.baeyens at jboss.com
Date: 2009-05-20 15:20:07 -0400 (Wed, 20 May 2009)
New Revision: 4861

Modified:
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/activity/Application.java
   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 add async activity docs

Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/activity/Application.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/activity/Application.java	2009-05-20 16:10:21 UTC (rev 4860)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/activity/Application.java	2009-05-20 19:20:07 UTC (rev 4861)
@@ -32,7 +32,4 @@
 
   public void calculatePrimes() {
   }
-  
-  public void runTestSuite() {
-  }
 }

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 16:10:21 UTC (rev 4860)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/activity/AsyncActivityTest.java	2009-05-20 19:20:07 UTC (rev 4861)
@@ -70,16 +70,6 @@
       .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 16:10:21 UTC (rev 4860)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.jpdl.xml	2009-05-20 19:20:07 UTC (rev 4861)
@@ -19,14 +19,6 @@
 	      class="org.jbpm.examples.async.activity.Application"
 	      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" 
-	      g="330,26,96,50">
 		<transition to="end"/>
 	</java>
 

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 16:10:21 UTC (rev 4860)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml	2009-05-20 19:20:07 UTC (rev 4861)
@@ -2207,10 +2207,96 @@
     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 
+    part of the currently ongoing transaction.  And then the originally invoked method 
     like e.g. <literal>startProcessInstanceById(...)</literal>
-    or <literal>signalProcessInstanceById(...)</literal> will return.  
+    or <literal>signalProcessInstanceById(...)</literal> will return.  When the 
+    asynchronous message is committed and then processed, it will start a new transaction
+    and resume execution where it left off. 
     </para>
+-   <table><title>Any activity attribute:</title>
+      <tgroup cols="5" rowsep="1" colsep="1">
+        <thead>
+          <row>
+            <entry>Attribute</entry>
+            <entry>Type</entry>
+            <entry>Default</entry>
+            <entry>Required?</entry>
+            <entry>Description</entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry><literal>continue</literal></entry>
+            <entry>{sync | async | exclusive}</entry>
+            <entry>sync</entry>
+            <entry>optional</entry>
+            <entry>indicates if an asynchronous continuation should be performed 
+            before the activity is executed.
+            </entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </table>
+    <para>Let's look at a couple of examples.</para>
+    
+    <section id="asyncactivity">
+      <title>Async activity</title>
+      <figure id="process.async.activity">
+        <title>The async activity example process</title>
+        <mediaobject><imageobject><imagedata align="center" fileref="images/process.async.activity.png"/></imageobject></mediaobject>
+      </figure>
+      <programlisting>&lt;process name=&quot;AsyncActivity&quot; xmlns=&quot;http://jbpm.org/4.0/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;generate pdf&quot;/&gt;
+  &lt;/start&gt;
+
+  &lt;java name=&quot;generate pdf&quot; 
+        <emphasis role="bold">continue=&quot;async&quot;</emphasis> 
+        class=&quot;org.jbpm.examples.async.activity.Application&quot;
+        method=&quot;generatePdf&quot; &gt;
+    &lt;transition to=&quot;calculate primes&quot;/&gt;
+  &lt;/java&gt;
+
+  &lt;java name=&quot;calculate primes&quot; 
+        <emphasis role="bold">continue=&quot;async&quot;</emphasis> 
+        class=&quot;org.jbpm.examples.async.activity.Application&quot;
+        method=&quot;calculatePrimes&quot;&gt;
+    &lt;transition to=&quot;end&quot;/&gt;
+  &lt;/java&gt;
+
+  &lt;end name=&quot;end&quot;/&gt;
+
+&lt;/process&gt;</programlisting>
+      <programlisting>ProcessInstance processInstance = 
+     executionService.startProcessInstanceByKey(&quot;AsyncActivity&quot;);
+String processInstanceId = processInstance.getId();</programlisting>
+      <para>Without the asynchronous continuations, this would be an all automatic 
+      process and the process would execute all the way up to the end
+      in method <literal>startProcessInstanceByKey</literal> 
+      </para>
+      <para>But with <literal>continue=&quot;async&quot;</literal> the execution only 
+      goes untill it is about to execute activity <literal>generate pdf</literal>. Then
+      An asynchronous continuation message is send and the <literal>startProcessInstanceByKey</literal> 
+      method returns.
+      </para>
+      <para>In a normal configuration, the job executor will pick up the message and execute 
+      it.  But for testing scenarios and for these examples we want to control
+      when messages are executed so the job executor is not configured.  Therefor
+      we have to execute the jobs manually like this:
+      </para>
+      <programlisting>Job job = managementService.createJobQuery()
+  .processInstanceId(processInstanceId)
+  .uniqueResult();
+managementService.executeJob(job.getDbid());</programlisting>
+      <para>That will bring the process until it's about to execute activity 
+      <literal>calculate primes</literal> and again an asynchronous message is 
+      send. 
+      </para>
+      <para>Then the message can be looked up again and when that message 
+      is executed, that transaction will run the execution till the end.
+      </para>
+    </section>
   </section>
 
   <section id="timer">




More information about the jbpm-commits mailing list