[jbpm-commits] JBoss JBPM SVN: r6003 - in jbpm4/trunk/modules/devguide/src/main/docbook/en: modules and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Sun Dec 20 22:07:54 EST 2009


Author: koen.aers at jboss.com
Date: 2009-12-20 22:07:53 -0500 (Sun, 20 Dec 2009)
New Revision: 6003

Added:
   jbpm4/trunk/modules/devguide/src/main/docbook/en/images/process.jms.png
   jbpm4/trunk/modules/devguide/src/main/docbook/en/images/process.rules.decision.png
   jbpm4/trunk/modules/devguide/src/main/docbook/en/images/process.rules.png
Modified:
   jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml
Log:
- jms activity documentation
- rules activity image
- rules decision image

Added: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/process.jms.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/process.jms.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/process.rules.decision.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/process.rules.decision.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/process.rules.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/process.rules.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml	2009-12-20 21:27:27 UTC (rev 6002)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml	2009-12-21 03:07:53 UTC (rev 6003)
@@ -851,6 +851,268 @@
     </para>
   </section>
   
+  <!-- ### JMS ####################################################### -->
+  <section id="jms">
+  
+    <title><literal>jms</literal> activity</title>
+    <para>
+      The <literal>jms</literal> activity provides users with convenience for sending JMS messages. 
+      At this moment the sending of three different types of JMS messages is possible: text, object 
+      and map. Specifying message properties is not yet supported.
+      In the future the functionality may be elaborated to cover this and more of the JMS specification.
+    </para>
+
+    <table><title><literal>jms</literal> attributes:</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>connection-factory</entry>
+            <entry>jndi name</entry>
+            <entry></entry>
+            <entry>true</entry>
+            <entry>the jndi name of the jms connection factory.  
+            </entry>
+          </row>
+          <row>
+            <entry>destination</entry>
+            <entry>jndi name</entry>
+            <entry></entry>
+            <entry>true</entry>
+            <entry>the jndi name of the jms queue or topic.  
+            </entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </table>
+    
+    <para>
+      The <literal>connection-factory</literal> and <literal>destination</literal> attributes are 
+      mandatory and respectively contain the names of the connection factory and destination (queue or topic) 
+      that will be used to lookup the corresponding objects in jndi. The specified message will be sent
+      to the destination that was obtained by this lookup.
+    </para>
+
+    <table><title><literal>jms</literal> elements:</title>
+      <tgroup cols="3" rowsep="1" colsep="1">
+        <thead>
+          <row>
+            <entry>Element</entry>
+            <entry>Multiplicity</entry>
+            <entry>Description</entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry><literal>text</literal></entry>
+            <entry>0..1</entry>
+            <entry>A string of text that will be used as payload for the JMS message.
+            </entry>
+          </row>
+          <row>
+            <entry><literal>object</literal></entry>
+            <entry>0..1</entry>
+            <entry>A serializable object that will be used as payload for the JMS message.
+            </entry>
+          </row>
+          <row>
+            <entry><literal>map</literal></entry>
+            <entry>0..1</entry>
+            <entry>A map of which the key-value entries will be used as payload for the JMS message.
+            </entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </table>
+    
+    <para>
+      Exactly one of the elements <literal>text</literal>, <literal>object</literal> or <literal>map</literal>
+      is mandatory. The presence of this element will determine the kind of message that will be sent to the 
+      queue obtained in the lookup mentioned above. This message will be a <literal>TextMessage</literal>, 
+      <literal>ObjectMessage</literal> or <literal>MapMessage</literal> respectively.
+    </para>
+        
+    <para>
+      In the following subsections the different types of supported messages will be explained. The used process
+      is in the three cases similar. The graphical representation of the process is shown below. 
+    </para>
+
+    <mediaobject><imageobject><imagedata align="center" fileref="images/process.jms.png"/></imageobject></mediaobject>
+    
+    <section id="jms.text">
+      <title>Text messages</title>
+      
+      <para>
+        The first possibility of sending JMS messages is to use text as its payload. In this case a JMS
+        <literal>TextMessage</literal> will be created and sent to the specified destination.
+        Consider the following process definition:
+      </para>
+      
+      <programlisting>&lt;process name=&quot;JMS_text_queue&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;send message&quot;/&gt;
+  &lt;/start&gt;
+
+  <emphasis role="bold">&lt;jms name=&quot;send message&quot;
+       connection-factory=&quot;ConnectionFactory&quot;
+       destination=&quot;queue/jbpm-test-queue&quot;&gt;
+    &lt;text&gt;This is the body&lt;/text&gt;
+    &lt;transition to=&quot;wait&quot;/&gt;
+  &lt;/jms&gt;</emphasis>
+
+  &lt;state name=&quot;wait&quot;/&gt;
+
+&lt;/process&gt;</programlisting>
+
+      <para>
+        As you may expect and as is shown in the following test case starting this process will cause
+        the JMS node to send a message to the queue with the name &quot;queue/jbpm-test-queue&quot;.
+        The factory used to create a connection to connect to this queue is named &quot;ConnectionFactory&quot;.
+        The payload of the message is the text string &quot;This is the body&quot;.
+      </para>
+      
+      <programlisting>public void testTextMessage() throws Exception 
+{  
+  Context context = new InitialContext();
+  Connection connection = (Connection)context.lookup(&quot;ConnectionFactory&quot;);
+  connection.start();
+  Session session = connection.createSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+  Queue queue = (Queue)context.lookup(&quot;queue/jbpm-test-queue&quot;);
+  MessageConsumer messageConsumer = session.createConsumer(queue);
+    
+  <emphasis role="bold">executionService.startProcessInstanceByKey(&quot;JMS_text_queue&quot;);
+  TextMessage textMessage = (TextMessage)messageConsumer.receive();
+  assertEquals(&quot;This is the body&quot;, textMessage.getText());</emphasis>
+   
+  connection.stop();
+  session.close();
+  connection.close();
+}</programlisting>
+
+      <para>
+        The relevant code is shown above in boldface. The rest of the method is boilerplate code needed to
+        setup a message consumer. We will omit this code in the subsequent examples.
+      </para>
+
+    </section>
+    
+    <section id="jms.object">
+    
+      <title>Object messages</title>
+      
+      <para>
+        The second possibility is to use a serializable object as the payload of the message. In this case a
+        JMS <literal>ObjectMessage</literal> will be created and sent to the specified destination.
+        Consider the following process definition:
+      </para>
+
+      <programlisting>&lt;process name=&quot;JMS_object_queue&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;send message&quot;/&gt;
+  &lt;/start&gt;
+
+  <emphasis role="bold">&lt;jms name=&quot;send message&quot;
+       connection-factory=&quot;ConnectionFactory&quot;
+       destination=&quot;queue/jbpm-test-queue&quot;&gt;
+    &lt;object expr=&quot;${object}&quot;/&gt;
+    &lt;transition to=&quot;wait&quot;/&gt;
+  &lt;/jms&gt;</emphasis>
+
+  &lt;state name=&quot;wait&quot;/&gt;
+
+&lt;/process&gt;</programlisting>
+    
+      <para>
+        As in the previous case a message will be sent to the queue with the name &quot;queue/jbpm-test-queue&quot;.
+        Also again a factory used to create a connection to connect to this queue is named &quot;ConnectionFactory&quot;.
+        But in this case the payload of the message is the serializable object that is obtained by 
+        evaluating the expression specified by the <literal>expr</literal> attribute. This is illustrated in the test case below.
+      </para>
+      
+      <programlisting>public void testQueueMessage() throws Exception 
+{  
+  // as before
+  ...  
+  <emphasis role="bold">Map&lt;String, Object&gt; variables = new HashMap&lt;String, Object&gt;();
+  variables.put(&quot;object&quot;, &quot;this is the object&quot;);
+  executionService.startProcessInstanceByKey(&quot;JMS_object_queue&quot;, variables);
+  ObjectMessage objectMessage = (ObjectMessage)messageConsumer.receive();
+  assertEquals(&quot;this is the object&quot;, objectMessage.getObject());</emphasis>
+  
+  // as before
+  ...
+}</programlisting>
+
+    </section>
+    
+    <section id="jms.map">
+    
+      <title>Map messages</title>
+      
+      <para>
+        In this third possibility the payload is constituted by the key-value entries of a map. This time a
+        JMS <literal>MapMessage</literal> will be created and sent to the specified destination.
+        Consider the following process definition:
+      </para>
+
+      <programlisting>&lt;process name=&quot;JMS_map_queue&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;send message&quot;/&gt;
+  &lt;/start&gt;
+
+  <emphasis role="bold">&lt;jms name=&quot;send message&quot;
+       connection-factory=&quot;ConnectionFactory&quot;
+       destination=&quot;queue/jbpm-test-queue&quot;&gt;
+    &lt;map&gt;
+      &lt;entry&gt;
+        &lt;key&gt;&lt;string value=&quot;x&quot;/&gt;&lt;/key&gt;
+        &lt;value&gt;&lt;string value=&quot;foo&quot;/&gt;&lt;/value&gt;
+      &lt;/entry&gt;
+    &lt;/map&gt;
+    &lt;transition to=&quot;wait&quot;/&gt;
+  &lt;/jms&gt;</emphasis>
+
+  &lt;state name=&quot;wait&quot;/&gt;
+
+&lt;/process&gt;</programlisting>
+
+      <para>
+        Again a message will be sent to the queue with the name &quot;queue/jbpm-test-queue&quot; and the 
+        factory used to create a connection to connect to this queue is named &quot;ConnectionFactory&quot;.
+        In this case the payload of the message are the specified key-value pairs of the map. 
+        It is illustrated in the test case below.
+      </para>
+      
+      <programlisting>public void testMapMessage() throws Exception 
+{  
+  // as before
+  ...  
+  <emphasis role="bold">executionService.startProcessInstanceByKey(&quot;JMS_map_queue&quot;);
+  MapMessage mapMessage = (MapMessage)messageConsumer.receive();
+  assertTrue(mapMessage.itemExists(&quot;x&quot;));
+  assertEquals(&quot;foo&quot;, mapMessage.getObject(&quot;x&quot;));</emphasis>
+  
+  // as before
+  ...
+}</programlisting>
+
+    </section>
+    
+  </section>  
+  
+    
+    
   <section>
   	<title>History session chain</title>
   	<para>



More information about the jbpm-commits mailing list