[jboss-cvs] JBoss Messaging SVN: r7607 - in trunk: examples/javaee and 37 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jul 27 05:04:37 EDT 2009


Author: ataylor
Date: 2009-07-27 05:04:36 -0400 (Mon, 27 Jul 2009)
New Revision: 7607

Added:
   trunk/examples/javaee/mdb-message-selector/
   trunk/examples/javaee/mdb-message-selector/build.xml
   trunk/examples/javaee/mdb-message-selector/config/
   trunk/examples/javaee/mdb-message-selector/config/ant.properties
   trunk/examples/javaee/mdb-message-selector/config/jndi.properties
   trunk/examples/javaee/mdb-message-selector/readme.html
   trunk/examples/javaee/mdb-message-selector/server/
   trunk/examples/javaee/mdb-message-selector/server/jbm-configuration.xml
   trunk/examples/javaee/mdb-message-selector/server/jbm-jms.xml
   trunk/examples/javaee/mdb-message-selector/server/jbm-users.xml
   trunk/examples/javaee/mdb-message-selector/src/
   trunk/examples/javaee/mdb-message-selector/src/org/
   trunk/examples/javaee/mdb-message-selector/src/org/jboss/
   trunk/examples/javaee/mdb-message-selector/src/org/jboss/javaee/
   trunk/examples/javaee/mdb-message-selector/src/org/jboss/javaee/example/
   trunk/examples/javaee/mdb-message-selector/src/org/jboss/javaee/example/MDBMessageSelectorClientExample.java
   trunk/examples/javaee/mdb-message-selector/src/org/jboss/javaee/example/server/
   trunk/examples/javaee/mdb-message-selector/src/org/jboss/javaee/example/server/MDBMessageSelectorExample.java
   trunk/examples/javaee/mdb-tx-send/
   trunk/examples/javaee/mdb-tx-send/build.xml
   trunk/examples/javaee/mdb-tx-send/config/
   trunk/examples/javaee/mdb-tx-send/config/ant.properties
   trunk/examples/javaee/mdb-tx-send/config/jndi.properties
   trunk/examples/javaee/mdb-tx-send/readme.html
   trunk/examples/javaee/mdb-tx-send/server/
   trunk/examples/javaee/mdb-tx-send/server/jbm-configuration.xml
   trunk/examples/javaee/mdb-tx-send/server/jbm-jms.xml
   trunk/examples/javaee/mdb-tx-send/server/jbm-users.xml
   trunk/examples/javaee/mdb-tx-send/src/
   trunk/examples/javaee/mdb-tx-send/src/org/
   trunk/examples/javaee/mdb-tx-send/src/org/jboss/
   trunk/examples/javaee/mdb-tx-send/src/org/jboss/javaee/
   trunk/examples/javaee/mdb-tx-send/src/org/jboss/javaee/example/
   trunk/examples/javaee/mdb-tx-send/src/org/jboss/javaee/example/MDBMessageSendTxClientExample.java
   trunk/examples/javaee/mdb-tx-send/src/org/jboss/javaee/example/server/
   trunk/examples/javaee/mdb-tx-send/src/org/jboss/javaee/example/server/MDBMessageSendTxExample.java
Modified:
   trunk/docs/user-manual/en/appserver-integration.xml
   trunk/examples/javaee/common/build.xml
   trunk/examples/javaee/jca-config/server2/ra.xml
   trunk/examples/javaee/mdb-bmp/readme.html
   trunk/examples/javaee/mdb-bmp/src/org/jboss/javaee/example/MDB_BMPClientExample.java
   trunk/examples/javaee/mdb-bmp/src/org/jboss/javaee/example/server/MDB_BMPExample.java
   trunk/examples/javaee/mdb-cmp-setrollbackonly/readme.html
   trunk/examples/javaee/mdb-cmp-setrollbackonly/src/org/jboss/javaee/example/MDB_CMP_SetRollbackOnlyClientExample.java
   trunk/examples/javaee/mdb-cmp-setrollbackonly/src/org/jboss/javaee/example/server/MDB_CMP_SetRollbackOnlyExample.java
   trunk/examples/javaee/mdb-cmp-tx-local/readme.html
   trunk/examples/javaee/mdb-cmp-tx-local/src/org/jboss/javaee/example/MDB_CMP_TxLocalClientExample.java
   trunk/examples/javaee/mdb-cmp-tx-local/src/org/jboss/javaee/example/server/MDB_CMP_TxLocalExample.java
   trunk/examples/javaee/mdb-cmp-tx-not-supported/readme.html
   trunk/examples/javaee/mdb-cmp-tx-not-supported/src/org/jboss/javaee/example/MDB_CMP_TxNotSupportedClientExample.java
   trunk/examples/javaee/mdb-cmp-tx-not-supported/src/org/jboss/javaee/example/server/MDB_CMP_TxNotSupported.java
   trunk/examples/javaee/mdb-cmp-tx-required/readme.html
   trunk/examples/javaee/mdb-cmp-tx-required/src/org/jboss/javaee/example/MDB_CMP_TxRequiredClientExample.java
   trunk/examples/javaee/messaging-javaee-examples.iml
   trunk/src/config/ra.xml
   trunk/src/main/org/jboss/messaging/ra/JBMRAProperties.java
   trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java
   trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivation.java
Log:
JCA fixes, more MDB examples and updated docs

Modified: trunk/docs/user-manual/en/appserver-integration.xml
===================================================================
--- trunk/docs/user-manual/en/appserver-integration.xml	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/docs/user-manual/en/appserver-integration.xml	2009-07-27 09:04:36 UTC (rev 7607)
@@ -5,11 +5,235 @@
         Enterprise Application Platform 5.1 or later. For details on installing JBoss Messaging in
         the JBoss Application Server refer to quick-start guide.</para>
     <para>JBoss Messaging can also be integrated with any other JEE compliant application server by
-        using the JBoss Messaging JCA adapter.</para>
+        using the JBoss Messaging JCA adapter. A JCA Adapter basically controls the incoming of
+        messages to Message Driven Beans and the outgoing of messages from other J2EE
+        components.</para>
     <para>This section explains the basics behind configuring the different JEE components in the
         AS.</para>
     <section>
-        <title>Using and Configuring the JCA Adapter</title>
+        <title>Configuring Message Driven Beans</title>
+        <para>The delivery of messages to an MDB using JBoss Messaging is configured on the JCA
+            Adapter via a configuration file <literal>ra.xml</literal> which can be found under in
+            the <literal>jms-ra.rar</literal> archive of directory.  By default this is configured
+            to consume messages using an InVM connector from the instance of JBoss Messaging running
+            within the application server. A full list of what is configurable is found later in
+            this chapter. </para>
+        <para>All MDB's however need to have the destination type and the destination configured.
+            The following example shows how this can be done via annotations.</para>
+        <programlisting>@MessageDriven(name = "MDBExample",
+               activationConfig =
+                     {
+                        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+                        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue")
+                     })
+public class MDBExample implements MessageListener
+{
+   public void onMessage(Message message)...
+}</programlisting>
+        <para>In this example you can see that the MDB will consume messages from a queue that is
+            mapped into JNDI with the binding <literal>queue/testQueue</literal>. This queue must be
+            preconfigured in the usual way using the JBoss Messaging configuration files.</para>
+        <section>
+            <title>Using Container Managed Persistence</title>
+            <para>When an MDB is using Container Managed Persistence, the delivery of the message is
+                done within the scope of an XA transaction. The commit or rollback of this
+                transaction is controlled by the container itself. If the transaction is rolled back
+                then the JBoss Message delivery semantics will kick in (by default this is to try
+                and redeliver the message up to 10 times before sending to a DLQ). Using annotations
+                this would be configured as follows:</para>
+            <programlisting>@MessageDriven(name = "MDB_CMP_TxRequiredExample",
+               activationConfig =
+                     {
+                        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+                        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue")
+                     })
+ at TransactionManagement(value= TransactionManagementType.CONTAINER)
+ at TransactionAttribute(value= TransactionAttributeType.REQUIRED)
+public class MDB_CMP_TxRequiredExample implements MessageListener
+{
+   public void onMessage(Message message)...
+}</programlisting>
+            <para>The <literal>TransactionManagement</literal> annotation tells the container to
+                treat this MDB to use Container Managed Persistence. The <literal
+                    >TransactionAttribute</literal> annotation tells the container that an XA
+                transaction is required for this MDB. Note that the only other valid value for this
+                is <literal>TransactionAttributeType.NOT_SUPPORTED</literal> which tells the
+                container that this MDB does not support XA transactions and one should not be
+                created.</para>
+            <para>It is also possible to inform the container that it must rollback the transaction
+                by calling <literal>setRollbackOnly</literal> on the <literal
+                    >MessageDrivenContext</literal>. The code for this would look something
+                like:</para>
+            <programlisting>   @Resource
+   MessageDrivenContext ctx;
+
+   public void onMessage(Message message)
+   {
+      try
+      {
+         //something here fails
+      }
+      catch (Exception e)
+      {
+         ctx.setRollbackOnly();
+      }
+   }</programlisting>
+            <para>If you don't want the over head of an xa transaction being created every time but
+                you would still like the message delivered within a transaction (i.e. you are only
+                using a JMS resource) then you can configure the MDB to use a local transaction.
+                This would be configured as such:</para>
+            <programlisting>@MessageDriven(name = "MDB_CMP_TxLocalExample",
+               activationConfig =
+                     {
+                           @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+                           @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue"),
+                           @ActivationConfigProperty(propertyName = "useLocalTx", propertyValue = "true")
+                     })
+ at TransactionManagement(value = TransactionManagementType.CONTAINER)
+ at TransactionAttribute(value = TransactionAttributeType.NOT_SUPPORTED)
+public class MDB_CMP_TxLocalExample implements MessageListener
+{
+   public void onMessage(Message message)...
+}</programlisting>
+        </section>
+        <section>
+            <title>Using Bean Managed Persistence</title>
+            <para>Message driven beans can also be configured to use Bean Managed Persistence. In
+                this case a User Transaction is created. This would be configured as follows:</para>
+            <programlisting>@MessageDriven(name = "MDB_BMPExample",
+               activationConfig =
+                     {
+                        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+                        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue"),
+                        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Dups-ok-acknowledge")
+                     })
+ at TransactionManagement(value= TransactionManagementType.BEAN)
+public class MDB_BMPExample implements MessageListener
+{
+   public void onMessage(Message message)
+}</programlisting>
+            <para>When using Bean Managed transactions the message will be acknowledged outside the
+                scope of the user transaction and use the acknowledge mode specified by the user
+                with the <literal>acknowledgeMode</literal> property. There are only 2 acceptable
+                values for this <literal>Auto-acknowledge</literal> and <literal
+                    >Dups-ok-acknowledge</literal>.Not that because the message delivery is outside
+                the scope of the transaction a failure within the MDB will not cause the message to
+                be redelivered.</para>
+            <para>A user would control the lifecycle of the transaction something like the
+                following:</para>
+            <programlisting>   @Resource
+   MessageDrivenContext ctx;
+
+   public void onMessage(Message message)
+   {
+      UserTransaction tx;
+      try
+      {
+         TextMessage textMessage = (TextMessage)message;
+
+         String text = textMessage.getText();
+
+         UserTransaction tx = ctx.getUserTransaction();
+
+         tx.begin();
+         //do some stuff within the transaction
+         tx.xommit();
+
+      }
+      catch (Exception e)
+      {
+         tx.rollback();
+      }
+   }</programlisting>
+        </section>
+        <section>
+            <title>Using Message Selectors with MDB's</title>
+            <para>It is also possible to use MDB's with message selectors. To do this simple define
+                your message selector as follows:</para>
+            <programlisting>@MessageDriven(name = "MDBMessageSelectorExample",
+               activationConfig =
+                     {
+                        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+                        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue"),
+                        @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "color = 'RED'")
+                     })
+ at TransactionManagement(value= TransactionManagementType.CONTAINER)
+ at TransactionAttribute(value= TransactionAttributeType.REQUIRED)
+public class MDBMessageSelectorExample implements MessageListener
+{
+   public void onMessage(Message message)....
+}</programlisting>
+        </section>
+    </section>
+    <section>
+        <title>Sending Messages from within J2EE components</title>
+        <para>The JCA adapter can also be used for sending messages. The Connection Factory to use
+            is configured by default in the <literal>jms-ds.xml</literal> file and is mapped to
+                <literal>java:/JmsXA</literal>. Using this from within a J2EE component will mean
+            that the sending of the message will be done as part of the XA transaction being used by
+            the component. This means that if the sending of the message fails the overall
+            transaction would rollback and the message redelivered. Heres an example of this from
+            within an MDB:</para>
+        <programlisting>@MessageDriven(name = "MDBMessageSendTxExample",
+               activationConfig =
+                     {
+                        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+                        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue")
+                     })
+ at TransactionManagement(value= TransactionManagementType.CONTAINER)
+ at TransactionAttribute(value= TransactionAttributeType.REQUIRED)
+public class MDBMessageSendTxExample implements MessageListener
+{
+   @Resource(mappedName = "java:JmsXA")
+   ConnectionFactory connectionFactory;
+
+   @Resource(mappedName = "queue/replyQueue")
+   Queue replyQueue;
+
+   public void onMessage(Message message)
+   {
+      Connection conn = null;
+      try
+      {
+         //Step 9. We know the client is sending a text message so we cast
+         TextMessage textMessage = (TextMessage)message;
+
+         //Step 10. get the text from the message.
+         String text = textMessage.getText();
+
+         System.out.println("message " + text);
+
+         conn = connectionFactory.createConnection();
+
+         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         MessageProducer producer = sess.createProducer(replyQueue);
+
+         producer.send(sess.createTextMessage("this is a reply"));
+
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         if(conn != null)
+         {
+            try
+            {
+               conn.close();
+            }
+            catch (JMSException e)
+            { 
+            }
+         }
+      }
+   }
+}</programlisting>
+    </section>
+    <section>
+        <title>Configuring the JCA Adapter</title>
         <para>The Java Connector Architecture (JCA) Adapter is what allows JBM to be integrated with
             JEE components such as MDB's and EJB's. It configures how components such as MDB's
             consume messages from the JBM server and also how components such as EJB's or Servlet's
@@ -33,12 +257,6 @@
          &lt;config-property-type>java.lang.String&lt;/config-property-type>
          &lt;config-property-value>jbm.remoting.invm.serverid=0&lt;/config-property-value>
       &lt;/config-property>
-       &lt;config-property>
-        &lt;description>Use XA methods to obtain connections?&lt;/description>
-        &lt;config-property-name>UseXA&lt;/config-property-name>
-        &lt;config-property-type>java.lang.Boolean&lt;/config-property-type>
-        &lt;config-property-value>true&lt;/config-property-value>
-      &lt;/config-property>
 
       &lt;outbound-resourceadapter>
          &lt;connection-definition>
@@ -143,9 +361,14 @@
                                 key=val;key=val; and will be specific to the connector used</entry>
                         </row>
                         <row>
+                            <entry>useLocalTx</entry>
+                            <entry>boolean</entry>
+                            <entry>True will enable local transaction optimisation.</entry>
+                        </row>
+                        <row>
                             <entry>UseXA</entry>
                             <entry>boolean</entry>
-                            <entry>True will enable XA transactions</entry>
+                            <entry>Whether XA should be used</entry>
                         </row>
                         <row>
                             <entry>UserName</entry>
@@ -360,56 +583,6 @@
         </section>
     </section>
     <section>
-        <title>Using JBM with MDBs in JBoss AS</title>
-        <para>Once the JCA Connector is configured, as shown previously, the MDB's can be configured
-            to consume messages from the MDB server.</para>
-        <para>This is best done by using the <literal>MessageDriven</literal> tag on the MDB itself.
-            The following shows an example.</para>
-        <programlisting>@MessageDriven(name = "MessageMDBExample",
-               activationConfig =
-                     {
-                        @ActivationConfigProperty(propertyName = "destinationType", 
-                        propertyValue = "javax.jms.Queue"),
-                        @ActivationConfigProperty(propertyName = "destination", 
-                        propertyValue = "queue/testQueue"),
-                        @ActivationConfigProperty(propertyName = "acknowledgeMode", 
-                        propertyValue = "Auto-acknowledge"),
-                        @ActivationConfigProperty(propertyName = "ConnectorClassName", 
-                        propertyValue = 
-            "org.jboss.messaging.integration.transports.netty.NettyConnectorFactory"),
-                        @ActivationConfigProperty(propertyName = "ConnectionParameters", 
-                        propertyValue = "jbm.remoting.netty.port=5545")
-                     })
-public class MDBRemoteExample implements MessageListener
-{
-   public void onMessage(Message message)
-   {
-      try
-      {
-         //Step 9. We know the client is sending a text message so we cast
-         TextMessage tm = (TextMessage)message;
-
-         //Step 10. get the text from the message.
-         String text = tm.getText();
-
-         System.out.println("message " + text + " received");
-         
-      }
-      catch (Exception e)
-      {
-         e.printStackTrace();
-      }
-   }
-}</programlisting>
-        <para>In this example we have configured the MDB to consume from the queue named <literal
-                >queue/testQueue</literal>. It is also possible to override properties for the
-            inbound resource adapter here is well. Here the MDB is configured to connect to a
-            different server. Any of the global properties defined on the adapter can be over ridden
-            via an <literal>ActivationConfigProperty</literal>.</para>
-        <para>It is also possible to define these properties in the <literal>web.xml</literal>
-            deployment descriptor. Refer to the JBoss AS documentation on how to do this.</para>
-    </section>
-    <section>
         <title>High Availability JNDI (HA-JNDI)</title>
         <para>If you are using JNDI to look-up JMS queues, topics and connection factories from a
             cluster of servers, it is likely you will want to use HA-JNDI so that your JNDI look-ups

Modified: trunk/examples/javaee/common/build.xml
===================================================================
--- trunk/examples/javaee/common/build.xml	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/examples/javaee/common/build.xml	2009-07-27 09:04:36 UTC (rev 7607)
@@ -138,7 +138,7 @@
          </fileset>
       </copy>
       <exec dir="${jboss.home}/bin" executable="sh" osfamily="unix">
-         <arg line="debug.sh -c ${example.name}-example-profile"/>
+         <arg line="run.sh -c ${example.name}-example-profile"/>
       </exec>
       <exec dir="${jboss.home}/bin" executable="cmd" osfamily="windows">
          <arg line="/c run.bat -c ${example.name}-example-profile"/>

Modified: trunk/examples/javaee/jca-config/server2/ra.xml
===================================================================
--- trunk/examples/javaee/jca-config/server2/ra.xml	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/examples/javaee/jca-config/server2/ra.xml	2009-07-27 09:04:36 UTC (rev 7607)
@@ -56,7 +56,13 @@
          <config-property-type>java.lang.String</config-property-type>
          <config-property-value>jbm.remoting.netty.port=5445</config-property-value>
       </config-property>
-
+      <config-property>
+        <description>Use XA?</description>
+        <config-property-name>UseXA</config-property-name>
+        <config-property-type>java.lang.Boolean</config-property-type>
+        <config-property-value>true</config-property-value>
+      </config-property>
+      
       <outbound-resourceadapter>
          <connection-definition>
             <managedconnectionfactory-class>org.jboss.messaging.ra.JBMManagedConnectionFactory</managedconnectionfactory-class>

Modified: trunk/examples/javaee/mdb-bmp/readme.html
===================================================================
--- trunk/examples/javaee/mdb-bmp/readme.html	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/examples/javaee/mdb-bmp/readme.html	2009-07-27 09:04:36 UTC (rev 7607)
@@ -1,12 +1,12 @@
 <html>
   <head>
-    <title>JBoss Messaging Java EE MDB Example</title>
+    <title>JBoss Messaging Java EE MDB BMP Example</title>
     <link rel="stylesheet" type="text/css" href="../../common/common.css">
   </head>
   <body>
-     <h1>Java EE MDB Example</h1>
+     <h1>Java EE MDB BMP Example</h1>
      <br>
-     <p>This example shows you how to send a message to an MDB</p>
+     <p>This example shows you how to send a message to an MDB configured to use Bean Managed Persistence</p>
      <p>
          The example will send deploy a simple MDB and demonstrate sending a message and the MDB consuming it
      </p>
@@ -76,7 +76,21 @@
             System.out.println("message " + text + " received");
             </code>
         </pre>
-        
+
+          <li>Now we can do something within a user transaction, lets just start and commit it
+        </li>
+        <pre>
+            <code>UserTransaction tx = ctx.getUserTransaction();
+
+             if(tx != null)
+             {
+                tx.begin();
+                System.out.println("we're in the middle of a transaction: " + tx);
+                tx.commit();
+             }
+            </code>
+        </pre>
+
         <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
 
         <pre>

Modified: trunk/examples/javaee/mdb-bmp/src/org/jboss/javaee/example/MDB_BMPClientExample.java
===================================================================
--- trunk/examples/javaee/mdb-bmp/src/org/jboss/javaee/example/MDB_BMPClientExample.java	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/examples/javaee/mdb-bmp/src/org/jboss/javaee/example/MDB_BMPClientExample.java	2009-07-27 09:04:36 UTC (rev 7607)
@@ -66,11 +66,11 @@
          //Step 8. Send the Message
          producer.send(message);
 
-          //Step 9 and 10 in MDBExample
+          //Step 9, 10 and 11 in MDB_BMPExample
       }
       finally
       {
-         //Step 11. Be sure to close our JMS resources!
+         //Step 12. Be sure to close our JMS resources!
          if (initialContext != null)
          {
             initialContext.close();

Modified: trunk/examples/javaee/mdb-bmp/src/org/jboss/javaee/example/server/MDB_BMPExample.java
===================================================================
--- trunk/examples/javaee/mdb-bmp/src/org/jboss/javaee/example/server/MDB_BMPExample.java	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/examples/javaee/mdb-bmp/src/org/jboss/javaee/example/server/MDB_BMPExample.java	2009-07-27 09:04:36 UTC (rev 7607)
@@ -60,7 +60,7 @@
 
          System.out.println("message " + text + " received");
 
-         //Step 3. lets look at the user transaction to make sure there isn't one.
+         //Step 11. lets look at the user transaction to make sure there isn't one.
          UserTransaction tx = ctx.getUserTransaction();
 
          if(tx != null)

Modified: trunk/examples/javaee/mdb-cmp-setrollbackonly/readme.html
===================================================================
--- trunk/examples/javaee/mdb-cmp-setrollbackonly/readme.html	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/examples/javaee/mdb-cmp-setrollbackonly/readme.html	2009-07-27 09:04:36 UTC (rev 7607)
@@ -1,12 +1,12 @@
 <html>
   <head>
-    <title>JBoss Messaging Java EE MDB Example</title>
+    <title>JBoss Messaging Java EE MDB SetRollbackOnly Example</title>
     <link rel="stylesheet" type="text/css" href="../../common/common.css">
   </head>
   <body>
-     <h1>Java EE MDB Example</h1>
+     <h1>Java EE MDB SetRollbackOnly Example</h1>
      <br>
-     <p>This example shows you how to send a message to an MDB</p>
+     <p>This example shows you how to send a message to an MDB and then roll back the transaction forcing re delivery</p>
      <p>
          The example will send deploy a simple MDB and demonstrate sending a message and the MDB consuming it
      </p>
@@ -69,13 +69,26 @@
            <code>TextMessage tm = (TextMessage)message;</code>
         </pre>
             
-        <li>The MDB gets the text and prints it
+        <li>The MDB gets the text and prints it, if its the first time we roll back
         </li>
         <pre>
-            <code>String text = tm.getText();
-            System.out.println("message " + text + " received");
+            <code> String text = textMessage.getText();
+
+             if(!textMessage.getJMSRedelivered())
+             {
+                //Step 11. rollback delivery of message if the first time
+                System.out.println("message " + text + " received for the first time");
+                ctx.setRollbackOnly();
+             }
             </code>
         </pre>
+
+         <li>The message is received again but this time we just print the text
+        </li>
+        <pre>
+            <code>System.out.println("message " + text + " received for the second time");
+            </code>
+        </pre>
         
         <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
 

Modified: trunk/examples/javaee/mdb-cmp-setrollbackonly/src/org/jboss/javaee/example/MDB_CMP_SetRollbackOnlyClientExample.java
===================================================================
--- trunk/examples/javaee/mdb-cmp-setrollbackonly/src/org/jboss/javaee/example/MDB_CMP_SetRollbackOnlyClientExample.java	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/examples/javaee/mdb-cmp-setrollbackonly/src/org/jboss/javaee/example/MDB_CMP_SetRollbackOnlyClientExample.java	2009-07-27 09:04:36 UTC (rev 7607)
@@ -66,11 +66,11 @@
          //Step 8. Send the Message
          producer.send(message);
 
-          //Step 9 and 10 in MDBExample
+          //Step 9, 10, 11 and 12 in MDB_CMP_SetRollbackOnlyExample
       }
       finally
       {
-         //Step 11. Be sure to close our JMS resources!
+         //Step 13. Be sure to close our JMS resources!
          if (initialContext != null)
          {
             initialContext.close();

Modified: trunk/examples/javaee/mdb-cmp-setrollbackonly/src/org/jboss/javaee/example/server/MDB_CMP_SetRollbackOnlyExample.java
===================================================================
--- trunk/examples/javaee/mdb-cmp-setrollbackonly/src/org/jboss/javaee/example/server/MDB_CMP_SetRollbackOnlyExample.java	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/examples/javaee/mdb-cmp-setrollbackonly/src/org/jboss/javaee/example/server/MDB_CMP_SetRollbackOnlyExample.java	2009-07-27 09:04:36 UTC (rev 7607)
@@ -59,13 +59,16 @@
 
          //Step 10. get the text from the message.
          String text = textMessage.getText();
+
          if(!textMessage.getJMSRedelivered())
          {
+            //Step 11. rollback delivery of message if the first time
             System.out.println("message " + text + " received for the first time");
             ctx.setRollbackOnly();
          }
          else
          {
+            //Step 12. read the message
             System.out.println("message " + text + " received for the second time");  
          }
 

Modified: trunk/examples/javaee/mdb-cmp-tx-local/readme.html
===================================================================
--- trunk/examples/javaee/mdb-cmp-tx-local/readme.html	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/examples/javaee/mdb-cmp-tx-local/readme.html	2009-07-27 09:04:36 UTC (rev 7607)
@@ -1,14 +1,14 @@
 <html>
   <head>
-    <title>JBoss Messaging Java EE MDB Example</title>
+    <title>JBoss Messaging Java EE MDB using a local transaction Example</title>
     <link rel="stylesheet" type="text/css" href="../../common/common.css">
   </head>
   <body>
-     <h1>Java EE MDB Example</h1>
+     <h1>Java EE MDB using a local transaction Example</h1>
      <br>
-     <p>This example shows you how to send a message to an MDB</p>
+     <p>This example shows you how to send a message to an MDB and deliver it within a local transaction</p>
      <p>
-         The example will send deploy a simple MDB and demonstrate sending a message and the MDB consuming it
+         The example will send deploy a simple MDB and demonstrate sending a message and the MDB consuming it, throwing an exception and the message being re delivered.
      </p>
      
      <h2>JBoss AS configuration</h2>
@@ -69,14 +69,36 @@
            <code>TextMessage tm = (TextMessage)message;</code>
         </pre>
             
-        <li>The MDB gets the text and prints it
+        <li>The MDB gets the text and prints it, we take a quick look at the transaction and throw an exception.
         </li>
         <pre>
-            <code>String text = tm.getText();
-            System.out.println("message " + text + " received");
+            <code>System.out.println("message " + text + " received");
+
+             if (!textMessage.getJMSRedelivered())
+             {
+                //Step 11. On first delivery get the transaction, take a look, and throw an exception
+                Transaction tx = tm.getTransaction();
+
+                if (tx != null)
+                {
+                   System.out.println("something is wrong, there should be no global transaction: " + tx);
+                }
+                else
+                {
+                   System.out.println("there is no global transaction, altho the messge delivery is using a local transaction");
+                   System.out.println("lets throw an exception and see what happens");
+                   throw new RuntimeException("DOH!");
+                }
+             }
             </code>
         </pre>
-        
+
+         <li>The MDB receives the message again and we print a message.
+            </li>
+        <pre>
+           <code>System.out.println("The message was redelivered since the message delivery used a local transaction");</code>
+        </pre>
+         
         <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
 
         <pre>

Modified: trunk/examples/javaee/mdb-cmp-tx-local/src/org/jboss/javaee/example/MDB_CMP_TxLocalClientExample.java
===================================================================
--- trunk/examples/javaee/mdb-cmp-tx-local/src/org/jboss/javaee/example/MDB_CMP_TxLocalClientExample.java	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/examples/javaee/mdb-cmp-tx-local/src/org/jboss/javaee/example/MDB_CMP_TxLocalClientExample.java	2009-07-27 09:04:36 UTC (rev 7607)
@@ -66,11 +66,11 @@
          //Step 8. Send the Message
          producer.send(message);
 
-          //Step 9 and 10 in MDBExample
+          //Step 9,,10, 11 and 12 in MDB_CMP_TxLocalExample
       }
       finally
       {
-         //Step 11. Be sure to close our JMS resources!
+         //Step 13. Be sure to close our JMS resources!
          if (initialContext != null)
          {
             initialContext.close();

Modified: trunk/examples/javaee/mdb-cmp-tx-local/src/org/jboss/javaee/example/server/MDB_CMP_TxLocalExample.java
===================================================================
--- trunk/examples/javaee/mdb-cmp-tx-local/src/org/jboss/javaee/example/server/MDB_CMP_TxLocalExample.java	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/examples/javaee/mdb-cmp-tx-local/src/org/jboss/javaee/example/server/MDB_CMP_TxLocalExample.java	2009-07-27 09:04:36 UTC (rev 7607)
@@ -67,6 +67,7 @@
 
          if (!textMessage.getJMSRedelivered())
          {
+            //Step 11. On first delivery get the transaction, take a look, and throw an exception
             Transaction tx = tm.getTransaction();
 
             if (tx != null)
@@ -82,6 +83,7 @@
          }
          else
          {
+            //Step 12. Print the message
             System.out.println("The message was redelivered since the message delivery used a local transaction");
          }
 

Modified: trunk/examples/javaee/mdb-cmp-tx-not-supported/readme.html
===================================================================
--- trunk/examples/javaee/mdb-cmp-tx-not-supported/readme.html	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/examples/javaee/mdb-cmp-tx-not-supported/readme.html	2009-07-27 09:04:36 UTC (rev 7607)
@@ -1,14 +1,14 @@
 <html>
   <head>
-    <title>JBoss Messaging Java EE MDB Example</title>
+    <title>JBoss Messaging Java EE MDB CMP with NOT_SUPPORTED transaction Example</title>
     <link rel="stylesheet" type="text/css" href="../../common/common.css">
   </head>
   <body>
-     <h1>Java EE MDB Example</h1>
+     <h1>Java EE MDB  with NOT_SUPPORTED transaction Example</h1>
      <br>
      <p>This example shows you how to send a message to an MDB</p>
      <p>
-         The example will send deploy a simple MDB and demonstrate sending a message and the MDB consuming it
+         The example will send deploy a simple MDB and demonstrate sending a message and the MDB consuming it but with a transaction as this MDB does not suuport one.
      </p>
      
      <h2>JBoss AS configuration</h2>
@@ -76,6 +76,18 @@
             System.out.println("message " + text + " received");
             </code>
         </pre>
+
+         <li>We look at the transaction to make sure there isn't one
+        </li>
+        <pre>
+            <code>Transaction tx = tm.getTransaction();
+
+             if(tx == null)
+             {
+                System.out.println("tx is null, just as expected");
+             }
+            </code>
+        </pre>
         
         <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
 

Modified: trunk/examples/javaee/mdb-cmp-tx-not-supported/src/org/jboss/javaee/example/MDB_CMP_TxNotSupportedClientExample.java
===================================================================
--- trunk/examples/javaee/mdb-cmp-tx-not-supported/src/org/jboss/javaee/example/MDB_CMP_TxNotSupportedClientExample.java	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/examples/javaee/mdb-cmp-tx-not-supported/src/org/jboss/javaee/example/MDB_CMP_TxNotSupportedClientExample.java	2009-07-27 09:04:36 UTC (rev 7607)
@@ -66,11 +66,11 @@
          //Step 8. Send the Message
          producer.send(message);
 
-          //Step 9 and 10 in MDBExample
+          //Step 9,10 and 11 in MDB_CMP_TxNotSupported
       }
       finally
       {
-         //Step 11. Be sure to close our JMS resources!
+         //Step 12. Be sure to close our JMS resources!
          if (initialContext != null)
          {
             initialContext.close();

Modified: trunk/examples/javaee/mdb-cmp-tx-not-supported/src/org/jboss/javaee/example/server/MDB_CMP_TxNotSupported.java
===================================================================
--- trunk/examples/javaee/mdb-cmp-tx-not-supported/src/org/jboss/javaee/example/server/MDB_CMP_TxNotSupported.java	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/examples/javaee/mdb-cmp-tx-not-supported/src/org/jboss/javaee/example/server/MDB_CMP_TxNotSupported.java	2009-07-27 09:04:36 UTC (rev 7607)
@@ -63,7 +63,7 @@
 
          System.out.println("message " + text + " received");
 
-         //Step 3. lets look at the transaction to make sure there isn't one.
+         //Step 11. lets look at the transaction to make sure there isn't one.
          Transaction tx = tm.getTransaction();
 
          if(tx == null)

Modified: trunk/examples/javaee/mdb-cmp-tx-required/readme.html
===================================================================
--- trunk/examples/javaee/mdb-cmp-tx-required/readme.html	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/examples/javaee/mdb-cmp-tx-required/readme.html	2009-07-27 09:04:36 UTC (rev 7607)
@@ -1,12 +1,12 @@
 <html>
   <head>
-    <title>JBoss Messaging Java EE MDB Example</title>
+    <title>JBoss Messaging Java EE MDB CMP using a transaction Example</title>
     <link rel="stylesheet" type="text/css" href="../../common/common.css">
   </head>
   <body>
-     <h1>Java EE MDB Example</h1>
+     <h1>Java EE MDB  CMP using a transaction Example</h1>
      <br>
-     <p>This example shows you how to send a message to an MDB</p>
+     <p>This example shows you how to send a message to an MDB that is delivered within a transaction</p>
      <p>
          The example will send deploy a simple MDB and demonstrate sending a message and the MDB consuming it
      </p>
@@ -68,6 +68,17 @@
         <pre>
            <code>TextMessage tm = (TextMessage)message;</code>
         </pre>
+
+         <li>We take alook at the transaction and see that it is running.
+            </li>
+        <pre>
+           <code>Transaction tx = tm.getTransaction();
+
+             if(tx != null)
+             {
+                System.out.println("we're in the middle of a transaction: " + tx);
+             }</code>
+        </pre>
             
         <li>The MDB gets the text and prints it
         </li>

Modified: trunk/examples/javaee/mdb-cmp-tx-required/src/org/jboss/javaee/example/MDB_CMP_TxRequiredClientExample.java
===================================================================
--- trunk/examples/javaee/mdb-cmp-tx-required/src/org/jboss/javaee/example/MDB_CMP_TxRequiredClientExample.java	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/examples/javaee/mdb-cmp-tx-required/src/org/jboss/javaee/example/MDB_CMP_TxRequiredClientExample.java	2009-07-27 09:04:36 UTC (rev 7607)
@@ -66,11 +66,11 @@
          //Step 8. Send the Message
          producer.send(message);
 
-          //Step 9 and 10 in MDBExample
+          //Step 9,10 and 11 in MDBExample
       }
       finally
       {
-         //Step 11. Be sure to close our JMS resources!
+         //Step 12. Be sure to close our JMS resources!
          if (initialContext != null)
          {
             initialContext.close();

Added: trunk/examples/javaee/mdb-message-selector/build.xml
===================================================================
--- trunk/examples/javaee/mdb-message-selector/build.xml	                        (rev 0)
+++ trunk/examples/javaee/mdb-message-selector/build.xml	2009-07-27 09:04:36 UTC (rev 7607)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- =========================================================================================== -->
+<!--                                                                                             -->
+<!-- JBoss, Home of Professional Open Source                                                     -->
+<!-- Copyright 2005, JBoss Inc., and individual contributors as indicated                        -->
+<!-- by the @authors tag. See the copyright.txt in the distribution for a                        -->
+<!-- full listing of individual contributors.                                                    -->
+<!--                                                                                             -->
+<!-- This is free software; you can redistribute it and/or modify it                             -->
+<!-- under the terms of the GNU Lesser General Public License as                                 -->
+<!-- published by the Free Software Foundation; either version 2.1 of                            -->
+<!-- the License, or (at your option) any later version.                                         -->
+<!--                                                                                             -->
+<!-- This software is distributed in the hope that it will be useful,                            -->
+<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of                              -->
+<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU                            -->
+<!-- Lesser General Public License for more details.                                             -->
+<!--                                                                                             -->
+<!-- You should have received a copy of the GNU Lesser General Public                            -->
+<!-- License along with this software; if not, write to the Free                                 -->
+<!-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA                          -->
+<!-- 02110-1301 USA, or see the FSF site: http://www.fsf.org.                                    -->
+<!--                                                                                             -->
+<!-- =========================================================================================== -->
+
+
+<project default="run" name="JBoss Messaging Java EE MDB Example">
+
+   <import file="../common/build.xml"/>
+   
+   <target name="run">
+      <antcall target="runExample">
+         <param name="example.classname" value="org.jboss.javaee.example.MDBMessageSelectorClientExample"/>
+      </antcall>
+   </target>
+</project>
\ No newline at end of file

Added: trunk/examples/javaee/mdb-message-selector/config/ant.properties
===================================================================
--- trunk/examples/javaee/mdb-message-selector/config/ant.properties	                        (rev 0)
+++ trunk/examples/javaee/mdb-message-selector/config/ant.properties	2009-07-27 09:04:36 UTC (rev 7607)
@@ -0,0 +1 @@
+example.name=mdb-message-selector
\ No newline at end of file

Added: trunk/examples/javaee/mdb-message-selector/config/jndi.properties
===================================================================
--- trunk/examples/javaee/mdb-message-selector/config/jndi.properties	                        (rev 0)
+++ trunk/examples/javaee/mdb-message-selector/config/jndi.properties	2009-07-27 09:04:36 UTC (rev 7607)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

Added: trunk/examples/javaee/mdb-message-selector/readme.html
===================================================================
--- trunk/examples/javaee/mdb-message-selector/readme.html	                        (rev 0)
+++ trunk/examples/javaee/mdb-message-selector/readme.html	2009-07-27 09:04:36 UTC (rev 7607)
@@ -0,0 +1,126 @@
+<html>
+  <head>
+    <title>JBoss Messaging Java EE MDB Message Selector Example</title>
+    <link rel="stylesheet" type="text/css" href="../../common/common.css">
+  </head>
+  <body>
+     <h1>Java EE MDB Message Selector Example</h1>
+     <br>
+     <p>This example shows you how to send a message to an MDB that is configured to use a message selector</p>
+     <p>
+         The example will send deploy a simple MDB and demonstrate sending a message and the MDB consuming only the message that matches the message selector.
+     </p>
+     
+     <h2>JBoss AS configuration</h2>
+     
+     <p>Please refer to JBoss Messaging Quickstart guide to <a href="../../../docs/quickstart-guide/en/html_single/index.html#installation.jboss">install it in JBoss AS 5<a></p>
+     
+     <h2>Example step-by-step</h2>
+     <p><i>To deploy and start the server, simply type <code>ant deploy</code> from the example directory</i></p>
+     <p><i>To run the example, simply type <code>ant</code> from the example directory</i></p>
+     <p><i>To remove the example profile, simply type <code>ant undeploy</code> from the example directory</i></p>
+     <p><i> ** make sure that JBOSS_HOME is set to the Jboss installation directory</i></p>
+     <br>
+     <ol>
+        <li>First we need to get an initial context so we can look-up the JMS connection factory and destination objects from JNDI. This initial context will get it's properties from the <code>jndi.properties</code> file in the directory <code>config</code></li>
+        <pre>
+           <code>initialContext = new InitialContext();</code>
+        </pre>
+
+        <li>We look up the JMS queue object from JNDI</li>
+        <pre>
+           <code>Queue queue = (Queue) initialContext.lookup("/queue/testQueue");</code>
+        </pre>
+
+        <li>We look up the JMS connection factory object from JNDI</li>
+        <pre>
+           <code>ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");</code>
+        </pre>
+
+        <li>We create a JMS connection</li>
+        <pre>
+           <code>connection = cf.createConnection();</code>
+        </pre>
+
+        <li>We create a JMS session. The session is created as non transacted and will auto acknowledge messages.</li>
+        <pre>
+           <code>Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);</code>
+        </pre>
+
+        <li>We create a JMS message producer on the session. This will be used to send the messages.</li>
+        <pre>
+          <code>MessageProducer messageProducer = session.createProducer(queue);</code>
+       </pre>
+
+        <li>We create a JMS text messages that we are going to send.</li>
+        <pre>
+           <code> TextMessage blueMessage = session.createTextMessage("This is a text message");</code>
+        </pre>
+
+        <li>Set the color property on the message to 'BLUE'.</li>
+        <pre>
+           <code> blueMessage.setStringProperty("color", "BLUE");</code>
+        </pre>
+
+        <li>We send messages to the queue</li>
+        <pre>
+           <code>messageProducer.send(blueMessage);</code>
+        </pre>
+
+         <li>We create a second JMS text message that we are going to send.</li>
+        <pre>
+           <code> TextMessage redMessage = session.createTextMessage("This is a text message");</code>
+        </pre>
+
+        <li>Set the color property on the message to 'RED'.</li>
+        <pre>
+           <code> redMessage.setStringProperty("color", "RED");</code>
+        </pre>
+
+        <li>We send messages to the queue</li>
+        <pre>
+           <code>messageProducer.send(redMessage);</code>
+        </pre>
+        
+        <li>The MDB receives the message<br />
+            We know the message is a TextMessage so we cast to it.
+            </li>
+        <pre>
+           <code>TextMessage tm = (TextMessage)message;</code>
+        </pre>
+
+         <li>We get the color property to check it
+            </li>
+        <pre>
+           <code>String color = textMessage.getStringProperty("color");</code>
+        </pre>
+            
+        <li>The MDB gets the text and color and print it
+        </li>
+        <pre>
+            <code>String text = tm.getText();
+            System.out.println("message " + text + " received color=" + color);
+            </code>
+        </pre>
+        
+        <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
+
+        <pre>
+           <code>finally
+           {
+              if (initialContext != null)
+              {
+                initialContext.close();
+              }
+              if (connection != null)
+              {
+                 connection.close();
+              }
+           }</code>
+        </pre>
+
+
+
+     </ol>
+  </body>
+</html>
\ No newline at end of file

Added: trunk/examples/javaee/mdb-message-selector/server/jbm-configuration.xml
===================================================================
--- trunk/examples/javaee/mdb-message-selector/server/jbm-configuration.xml	                        (rev 0)
+++ trunk/examples/javaee/mdb-message-selector/server/jbm-configuration.xml	2009-07-27 09:04:36 UTC (rev 7607)
@@ -0,0 +1,67 @@
+<configuration xmlns="urn:jboss:messaging"
+               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+               xsi:schemaLocation="urn:jboss:messaging /schema/jbm-configuration.xsd">
+
+   <bindings-directory>${jboss.server.data.dir}/messaging/bindings</bindings-directory>
+
+   <journal-directory>${jboss.server.data.dir}/messaging/journal</journal-directory>
+
+   <large-messages-directory>${jboss.server.data.dir}/messaging/largemessages</large-messages-directory>
+
+   <paging-directory>${jboss.server.data.dir}/messaging/paging</paging-directory>
+
+   <!-- Connectors -->
+   <connectors>
+      <connector name="netty">
+         <factory-class>org.jboss.messaging.integration.transports.netty.NettyConnectorFactory</factory-class>
+         <param key="jbm.remoting.netty.host" value="${jbm.remoting.netty.host:localhost}" type="String"/>
+         <param key="jbm.remoting.netty.port" value="${jbm.remoting.netty.port:5445}" type="Integer"/>
+      </connector>
+
+      <connector name="in-vm">
+         <factory-class>org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory</factory-class>
+      </connector>
+
+   </connectors>
+
+   <!-- Acceptors -->
+   <acceptors>
+      <!-- In VM acceptor -->
+      <acceptor name="in-vm">
+         <factory-class>org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory</factory-class>
+         <param key="jbm.remoting.invm.serverid" value="0" type="Integer"/>
+      </acceptor>
+
+      <!-- Netty TCP Acceptor -->
+      <acceptor name="netty">
+         <factory-class>org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory</factory-class>
+         <param key="jbm.remoting.netty.host" value="${jbm.remoting.netty.host:localhost}" type="String"/>
+         <param key="jbm.remoting.netty.port" value="${jbm.remoting.netty.port:5445}" type="Integer"/>
+      </acceptor>
+   </acceptors>
+
+    <security-settings>
+      <security-setting match="#">
+         <permission type="createTempQueue" roles="guest"/>
+         <permission type="deleteTempQueue" roles="guest"/>
+         <permission type="consume" roles="guest"/>
+         <permission type="send" roles="guest"/>
+      </security-setting>
+   </security-settings>
+
+   <address-settings>
+      <!--default for catch all-->
+      <address-setting match="#">
+         <clustered>false</clustered>
+         <dead-letter-address>jms.queue.DLQ</dead-letter-address>
+         <expiry-address>jms.queue.ExpiryQueue</expiry-address>
+         <redelivery-delay>0</redelivery-delay>
+         <max-size-bytes>-1</max-size-bytes>
+         <page-size-bytes>10485760</page-size-bytes>
+         <distribution-policy-class>org.jboss.messaging.core.server.impl.RoundRobinDistributor</distribution-policy-class>
+         <message-counter-history-day-limit>10</message-counter-history-day-limit>
+      </address-setting>
+   </address-settings>
+
+
+</configuration>

Added: trunk/examples/javaee/mdb-message-selector/server/jbm-jms.xml
===================================================================
--- trunk/examples/javaee/mdb-message-selector/server/jbm-jms.xml	                        (rev 0)
+++ trunk/examples/javaee/mdb-message-selector/server/jbm-jms.xml	2009-07-27 09:04:36 UTC (rev 7607)
@@ -0,0 +1,16 @@
+<configuration xmlns="urn:jboss:messaging"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:messaging /schema/jbm-jms.xsd">
+
+   <connection-factory name="ConnectionFactory">
+      <connector-ref connector-name="netty"/>
+      <entries>
+         <entry name="ConnectionFactory"/>
+         <entry name="XAConnectionFactory"/>
+      </entries>
+   </connection-factory>
+
+   <queue name="testQueue">
+      <entry name="/queue/testQueue"/>
+   </queue>
+</configuration>
\ No newline at end of file

Added: trunk/examples/javaee/mdb-message-selector/server/jbm-users.xml
===================================================================
--- trunk/examples/javaee/mdb-message-selector/server/jbm-users.xml	                        (rev 0)
+++ trunk/examples/javaee/mdb-message-selector/server/jbm-users.xml	2009-07-27 09:04:36 UTC (rev 7607)
@@ -0,0 +1,7 @@
+<configuration xmlns="urn:jboss:messaging" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:messaging /schema/jbm-users.xsd">
+   <!-- the default user.  this is used where username is null-->
+   <defaultuser name="guest" password="guest">
+      <role name="guest"/>
+   </defaultuser>
+</configuration>
\ No newline at end of file

Added: trunk/examples/javaee/mdb-message-selector/src/org/jboss/javaee/example/MDBMessageSelectorClientExample.java
===================================================================
--- trunk/examples/javaee/mdb-message-selector/src/org/jboss/javaee/example/MDBMessageSelectorClientExample.java	                        (rev 0)
+++ trunk/examples/javaee/mdb-message-selector/src/org/jboss/javaee/example/MDBMessageSelectorClientExample.java	2009-07-27 09:04:36 UTC (rev 7607)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.javaee.example;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+
+/**
+ * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ */
+public class MDBMessageSelectorClientExample
+{
+   public static void main(String[] args) throws Exception
+   {
+      Connection connection = null;
+      InitialContext initialContext = null;
+      try
+      {
+         //Step 1. Create an initial context to perform the JNDI lookup.
+         initialContext = new InitialContext();
+
+         //Step 2. Perfom a lookup on the queue
+         Queue queue = (Queue) initialContext.lookup("/queue/testQueue");
+
+         //Step 3. Perform a lookup on the Connection Factory
+         ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");
+
+         //Step 4.Create a JMS Connection
+         connection = cf.createConnection();
+
+         //Step 5. Create a JMS Session
+         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         //Step 6. Create a JMS Message Producer
+         MessageProducer producer = session.createProducer(queue);
+
+         //Step 7. Create a Text Message and set the color property to blue
+         TextMessage blueMessage = session.createTextMessage("This is a text message");
+
+         blueMessage.setStringProperty("color", "BLUE");
+
+         System.out.println("Sent message: " + blueMessage.getText() + " color=BLUE");
+
+         //Step 8. Send the Message
+         producer.send(blueMessage);
+
+         //Step 9. create another message and set the color property to red
+         TextMessage redMessage = session.createTextMessage("This is a text message");
+
+         redMessage.setStringProperty("color", "RED");
+
+         System.out.println("Sent message: " + redMessage.getText() + " color=RED");
+
+         //Step 10. Send the Message
+         producer.send(redMessage);
+          //Step 10,11 and 12 in MDBMessageSelectorExample
+      }
+      finally
+      {
+         //Step 13. Be sure to close our JMS resources!
+         if (initialContext != null)
+         {
+            initialContext.close();
+         }
+         if(connection != null)
+         {
+            connection.close();
+         }
+      }
+   }
+}
\ No newline at end of file

Added: trunk/examples/javaee/mdb-message-selector/src/org/jboss/javaee/example/server/MDBMessageSelectorExample.java
===================================================================
--- trunk/examples/javaee/mdb-message-selector/src/org/jboss/javaee/example/server/MDBMessageSelectorExample.java	                        (rev 0)
+++ trunk/examples/javaee/mdb-message-selector/src/org/jboss/javaee/example/server/MDBMessageSelectorExample.java	2009-07-27 09:04:36 UTC (rev 7607)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.javaee.example.server;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+/**
+ * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ */
+ at MessageDriven(name = "MDBMessageSelectorExample",
+               activationConfig =
+                     {
+                        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+                        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue"),
+                        @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "color = 'RED'")
+                     })
+ at TransactionManagement(value= TransactionManagementType.CONTAINER)
+ at TransactionAttribute(value= TransactionAttributeType.REQUIRED)
+public class MDBMessageSelectorExample implements MessageListener
+{
+   public void onMessage(Message message)
+   {
+      try
+      {
+         //Step 11. We know the client is sending a text message so we cast
+         TextMessage textMessage = (TextMessage)message;
+
+         //Step 12. get the text from the message.
+         String text = textMessage.getText();
+
+         //Step 13. We check we received the right color of message
+         String color = textMessage.getStringProperty("color");
+
+         System.out.println("message " + text + " received color=" + color);
+
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+   }
+}
\ No newline at end of file

Added: trunk/examples/javaee/mdb-tx-send/build.xml
===================================================================
--- trunk/examples/javaee/mdb-tx-send/build.xml	                        (rev 0)
+++ trunk/examples/javaee/mdb-tx-send/build.xml	2009-07-27 09:04:36 UTC (rev 7607)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- =========================================================================================== -->
+<!--                                                                                             -->
+<!-- JBoss, Home of Professional Open Source                                                     -->
+<!-- Copyright 2005, JBoss Inc., and individual contributors as indicated                        -->
+<!-- by the @authors tag. See the copyright.txt in the distribution for a                        -->
+<!-- full listing of individual contributors.                                                    -->
+<!--                                                                                             -->
+<!-- This is free software; you can redistribute it and/or modify it                             -->
+<!-- under the terms of the GNU Lesser General Public License as                                 -->
+<!-- published by the Free Software Foundation; either version 2.1 of                            -->
+<!-- the License, or (at your option) any later version.                                         -->
+<!--                                                                                             -->
+<!-- This software is distributed in the hope that it will be useful,                            -->
+<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of                              -->
+<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU                            -->
+<!-- Lesser General Public License for more details.                                             -->
+<!--                                                                                             -->
+<!-- You should have received a copy of the GNU Lesser General Public                            -->
+<!-- License along with this software; if not, write to the Free                                 -->
+<!-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA                          -->
+<!-- 02110-1301 USA, or see the FSF site: http://www.fsf.org.                                    -->
+<!--                                                                                             -->
+<!-- =========================================================================================== -->
+
+
+<project default="run" name="JBoss Messaging Java EE MDB Example">
+
+   <import file="../common/build.xml"/>
+   
+   <target name="run">
+      <antcall target="runExample">
+         <param name="example.classname" value="org.jboss.javaee.example.MDBMessageSendTxClientExample"/>
+      </antcall>
+   </target>
+</project>
\ No newline at end of file

Added: trunk/examples/javaee/mdb-tx-send/config/ant.properties
===================================================================
--- trunk/examples/javaee/mdb-tx-send/config/ant.properties	                        (rev 0)
+++ trunk/examples/javaee/mdb-tx-send/config/ant.properties	2009-07-27 09:04:36 UTC (rev 7607)
@@ -0,0 +1 @@
+example.name=mdb-tx-send
\ No newline at end of file

Added: trunk/examples/javaee/mdb-tx-send/config/jndi.properties
===================================================================
--- trunk/examples/javaee/mdb-tx-send/config/jndi.properties	                        (rev 0)
+++ trunk/examples/javaee/mdb-tx-send/config/jndi.properties	2009-07-27 09:04:36 UTC (rev 7607)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

Added: trunk/examples/javaee/mdb-tx-send/readme.html
===================================================================
--- trunk/examples/javaee/mdb-tx-send/readme.html	                        (rev 0)
+++ trunk/examples/javaee/mdb-tx-send/readme.html	2009-07-27 09:04:36 UTC (rev 7607)
@@ -0,0 +1,158 @@
+<html>
+  <head>
+    <title>JBoss Messaging Java EE MDB Send Example</title>
+    <link rel="stylesheet" type="text/css" href="../../common/common.css">
+  </head>
+  <body>
+     <h1>Java EE MDB Send Example</h1>
+     <br>
+     <p>This example shows you how to send a message to an MDB that returns a reply using the same XA transaction</p>
+     <p>
+         The example will send deploy a simple MDB and demonstrate sending a message and the MDB consuming it
+     </p>
+     
+     <h2>JBoss AS configuration</h2>
+     
+     <p>Please refer to JBoss Messaging Quickstart guide to <a href="../../../docs/quickstart-guide/en/html_single/index.html#installation.jboss">install it in JBoss AS 5<a></p>
+     
+     <h2>Example step-by-step</h2>
+     <p><i>To deploy and start the server, simply type <code>ant deploy</code> from the example directory</i></p>
+     <p><i>To run the example, simply type <code>ant</code> from the example directory</i></p>
+     <p><i>To remove the example profile, simply type <code>ant undeploy</code> from the example directory</i></p>
+     <p><i> ** make sure that JBOSS_HOME is set to the Jboss installation directory</i></p>
+     <br>
+     <ol>
+        <li>First we need to get an initial context so we can look-up the JMS connection factory and destination objects from JNDI. This initial context will get it's properties from the <code>jndi.properties</code> file in the directory <code>config</code></li>
+        <pre>
+           <code>initialContext = new InitialContext();</code>
+        </pre>
+
+        <li>We look up the JMS queue object from JNDI</li>
+        <pre>
+           <code>Queue queue = (Queue) initialContext.lookup("/queue/testQueue");</code>
+        </pre>
+
+        <li>We look up the JMS connection factory object from JNDI</li>
+        <pre>
+           <code>ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");</code>
+        </pre>
+
+        <li>We create a JMS connection</li>
+        <pre>
+           <code>connection = cf.createConnection();</code>
+        </pre>
+
+        <li>We create a JMS session. The session is created as non transacted and will auto acknowledge messages.</li>
+        <pre>
+           <code>Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);</code>
+        </pre>
+
+        <li>We create a JMS message producer on the session. This will be used to send the messages.</li>
+        <pre>
+          <code>MessageProducer messageProducer = session.createProducer(queue);</code>
+       </pre>
+
+        <li>We create a JMS text messages that we are going to send.</li>
+        <pre>
+           <code> TextMessage message = session.createTextMessage("This is a text message");</code>
+        </pre>
+
+        <li>We send messages to the queue</li>
+        <pre>
+           <code>messageProducer.send(message);</code>
+        </pre>
+        
+        <li>The MDB receives the message<br />
+            We know the message is a TextMessage so we cast to it.
+            </li>
+        <pre>
+           <code>TextMessage tm = (TextMessage)message;</code>
+        </pre>
+            
+        <li>The MDB gets the text and prints it
+        </li>
+        <pre>
+            <code>String text = tm.getText();
+            System.out.println("message " + text + " received");
+            </code>
+        </pre>
+
+         <li>The MDB creates a JMS connection
+        </li>
+        <pre>
+            <code>conn = connectionFactory.createConnection();
+            </code>
+        </pre>
+
+         <li>The MDB creates a JMS session
+        </li>
+        <pre>
+            <code>Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            </code>
+        </pre>
+
+         <li>The MDB creates a JMS message producer
+        </li>
+        <pre>
+            <code>MessageProducer producer = sess.createProducer(replyQueue);
+            </code>
+        </pre>
+
+         <li>The MDB creates a text message and sends it to the reply queue
+        </li>
+        <pre>
+            <code>producer.send(sess.createTextMessage("this is a reply"));
+            </code>
+        </pre>
+
+        <li>The Client looks up the reply queue
+        </li>
+        <pre>
+            <code>queue = (Queue) initialContext.lookup("/queue/replyQueue");
+            </code>
+        </pre>
+
+         <li>The Client creates a JMS message consumer
+        </li>
+        <pre>
+            <code>MessageConsumer messageConsumer = session.createConsumer(queue);
+            </code>
+        </pre>
+
+          <li>The Client starts the connection so it can receive messages
+        </li>
+        <pre>
+            <code>connection.start();
+            </code>
+        </pre>
+
+          <li>The Client receives the reply and prints it out
+        </li>
+        <pre>
+            <code>message = (TextMessage) messageConsumer.receive(5000);
+
+            System.out.println("message.getText() = " + message.getText());
+            </code>
+        </pre>
+        
+        <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
+
+        <pre>
+           <code>finally
+           {
+              if (initialContext != null)
+              {
+                initialContext.close();
+              }
+              if (connection != null)
+              {
+                 connection.close();
+              }
+           }</code>
+        </pre>
+
+
+
+     </ol>
+  </body>
+</html>
\ No newline at end of file

Added: trunk/examples/javaee/mdb-tx-send/server/jbm-configuration.xml
===================================================================
--- trunk/examples/javaee/mdb-tx-send/server/jbm-configuration.xml	                        (rev 0)
+++ trunk/examples/javaee/mdb-tx-send/server/jbm-configuration.xml	2009-07-27 09:04:36 UTC (rev 7607)
@@ -0,0 +1,67 @@
+<configuration xmlns="urn:jboss:messaging"
+               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+               xsi:schemaLocation="urn:jboss:messaging /schema/jbm-configuration.xsd">
+
+   <bindings-directory>${jboss.server.data.dir}/messaging/bindings</bindings-directory>
+
+   <journal-directory>${jboss.server.data.dir}/messaging/journal</journal-directory>
+
+   <large-messages-directory>${jboss.server.data.dir}/messaging/largemessages</large-messages-directory>
+
+   <paging-directory>${jboss.server.data.dir}/messaging/paging</paging-directory>
+
+   <!-- Connectors -->
+   <connectors>
+      <connector name="netty">
+         <factory-class>org.jboss.messaging.integration.transports.netty.NettyConnectorFactory</factory-class>
+         <param key="jbm.remoting.netty.host" value="${jbm.remoting.netty.host:localhost}" type="String"/>
+         <param key="jbm.remoting.netty.port" value="${jbm.remoting.netty.port:5445}" type="Integer"/>
+      </connector>
+
+      <connector name="in-vm">
+         <factory-class>org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory</factory-class>
+      </connector>
+
+   </connectors>
+
+   <!-- Acceptors -->
+   <acceptors>
+      <!-- In VM acceptor -->
+      <acceptor name="in-vm">
+         <factory-class>org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory</factory-class>
+         <param key="jbm.remoting.invm.serverid" value="0" type="Integer"/>
+      </acceptor>
+
+      <!-- Netty TCP Acceptor -->
+      <acceptor name="netty">
+         <factory-class>org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory</factory-class>
+         <param key="jbm.remoting.netty.host" value="${jbm.remoting.netty.host:localhost}" type="String"/>
+         <param key="jbm.remoting.netty.port" value="${jbm.remoting.netty.port:5445}" type="Integer"/>
+      </acceptor>
+   </acceptors>
+
+    <security-settings>
+      <security-setting match="#">
+         <permission type="createTempQueue" roles="guest"/>
+         <permission type="deleteTempQueue" roles="guest"/>
+         <permission type="consume" roles="guest"/>
+         <permission type="send" roles="guest"/>
+      </security-setting>
+   </security-settings>
+
+   <address-settings>
+      <!--default for catch all-->
+      <address-setting match="#">
+         <clustered>false</clustered>
+         <dead-letter-address>jms.queue.DLQ</dead-letter-address>
+         <expiry-address>jms.queue.ExpiryQueue</expiry-address>
+         <redelivery-delay>0</redelivery-delay>
+         <max-size-bytes>-1</max-size-bytes>
+         <page-size-bytes>10485760</page-size-bytes>
+         <distribution-policy-class>org.jboss.messaging.core.server.impl.RoundRobinDistributor</distribution-policy-class>
+         <message-counter-history-day-limit>10</message-counter-history-day-limit>
+      </address-setting>
+   </address-settings>
+
+
+</configuration>

Added: trunk/examples/javaee/mdb-tx-send/server/jbm-jms.xml
===================================================================
--- trunk/examples/javaee/mdb-tx-send/server/jbm-jms.xml	                        (rev 0)
+++ trunk/examples/javaee/mdb-tx-send/server/jbm-jms.xml	2009-07-27 09:04:36 UTC (rev 7607)
@@ -0,0 +1,21 @@
+<configuration xmlns="urn:jboss:messaging"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:messaging /schema/jbm-jms.xsd">
+
+   <connection-factory name="ConnectionFactory">
+      <connector-ref connector-name="netty"/>
+      <entries>
+         <entry name="ConnectionFactory"/>
+         <entry name="XAConnectionFactory"/>
+      </entries>
+   </connection-factory>
+
+   <queue name="testQueue">
+      <entry name="/queue/testQueue"/>
+   </queue>
+
+   <queue name="replyQueue">
+      <entry name="/queue/replyQueue"/>
+   </queue>
+
+</configuration>
\ No newline at end of file

Added: trunk/examples/javaee/mdb-tx-send/server/jbm-users.xml
===================================================================
--- trunk/examples/javaee/mdb-tx-send/server/jbm-users.xml	                        (rev 0)
+++ trunk/examples/javaee/mdb-tx-send/server/jbm-users.xml	2009-07-27 09:04:36 UTC (rev 7607)
@@ -0,0 +1,7 @@
+<configuration xmlns="urn:jboss:messaging" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:messaging /schema/jbm-users.xsd">
+   <!-- the default user.  this is used where username is null-->
+   <defaultuser name="guest" password="guest">
+      <role name="guest"/>
+   </defaultuser>
+</configuration>
\ No newline at end of file

Added: trunk/examples/javaee/mdb-tx-send/src/org/jboss/javaee/example/MDBMessageSendTxClientExample.java
===================================================================
--- trunk/examples/javaee/mdb-tx-send/src/org/jboss/javaee/example/MDBMessageSendTxClientExample.java	                        (rev 0)
+++ trunk/examples/javaee/mdb-tx-send/src/org/jboss/javaee/example/MDBMessageSendTxClientExample.java	2009-07-27 09:04:36 UTC (rev 7607)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.javaee.example;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+
+/**
+ * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ */
+public class MDBMessageSendTxClientExample
+{
+   public static void main(String[] args) throws Exception
+   {
+      Connection connection = null;
+      InitialContext initialContext = null;
+      try
+      {
+         //Step 1. Create an initial context to perform the JNDI lookup.
+         initialContext = new InitialContext();
+
+         //Step 2. Perfom a lookup on the queue
+         Queue queue = (Queue) initialContext.lookup("/queue/testQueue");
+
+         //Step 3. Perform a lookup on the Connection Factory
+         ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");
+
+         //Step 4.Create a JMS Connection
+         connection = cf.createConnection();
+
+         //Step 5. Create a JMS Session
+         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         //Step 6. Create a JMS Message Producer
+         MessageProducer producer = session.createProducer(queue);
+
+         //Step 7. Create a Text Message
+         TextMessage message = session.createTextMessage("This is a text message");
+
+         System.out.println("Sent message: " + message.getText());
+
+         //Step 8. Send the Message
+         producer.send(message);
+
+         //Step 15. We lookup the reply queue
+         queue = (Queue) initialContext.lookup("/queue/replyQueue");
+
+         //Step 16. We create a JMS message consumer
+         MessageConsumer messageConsumer = session.createConsumer(queue);
+
+         //Step 17. We start the connedction so we can receive messages
+         connection.start();
+
+         //Step 18. We receive the message and print it out
+         message = (TextMessage) messageConsumer.receive(5000);
+
+         System.out.println("message.getText() = " + message.getText());
+
+      }
+      finally
+      {
+         //Step 19. Be sure to close our JMS resources!
+         if (initialContext != null)
+         {
+            initialContext.close();
+         }
+         if(connection != null)
+         {
+            connection.close();
+         }
+      }
+   }
+}
\ No newline at end of file

Added: trunk/examples/javaee/mdb-tx-send/src/org/jboss/javaee/example/server/MDBMessageSendTxExample.java
===================================================================
--- trunk/examples/javaee/mdb-tx-send/src/org/jboss/javaee/example/server/MDBMessageSendTxExample.java	                        (rev 0)
+++ trunk/examples/javaee/mdb-tx-send/src/org/jboss/javaee/example/server/MDBMessageSendTxExample.java	2009-07-27 09:04:36 UTC (rev 7607)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.javaee.example.server;
+
+import javax.annotation.Resource;
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+/**
+ * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ */
+ at MessageDriven(name = "MDBMessageSendTxExample",
+               activationConfig =
+                     {
+                        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+                        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue")
+                     })
+ at TransactionManagement(value= TransactionManagementType.CONTAINER)
+ at TransactionAttribute(value= TransactionAttributeType.REQUIRED)
+public class MDBMessageSendTxExample implements MessageListener
+{
+   @Resource(mappedName = "java:JmsXA")
+   ConnectionFactory connectionFactory;
+
+   @Resource(mappedName = "queue/replyQueue")
+   Queue replyQueue;
+
+   public void onMessage(Message message)
+   {
+      Connection conn = null;
+      try
+      {
+         //Step 9. We know the client is sending a text message so we cast
+         TextMessage textMessage = (TextMessage)message;
+
+         //Step 10. get the text from the message.
+         String text = textMessage.getText();
+
+         System.out.println("message " + text);
+
+         //Step 11. we create a JMS connection
+         conn = connectionFactory.createConnection();
+
+         //Step 12. We create a JMS session
+         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         //Step 13. we create a producer for the reply queue
+         MessageProducer producer = sess.createProducer(replyQueue);
+
+         //Step 14. we create a message and send it
+         producer.send(sess.createTextMessage("this is a reply"));
+
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         if(conn != null)
+         {
+            try
+            {
+               conn.close();
+            }
+            catch (JMSException e)
+            { 
+            }
+         }
+      }
+   }
+}
\ No newline at end of file

Modified: trunk/examples/javaee/messaging-javaee-examples.iml
===================================================================
--- trunk/examples/javaee/messaging-javaee-examples.iml	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/examples/javaee/messaging-javaee-examples.iml	2009-07-27 09:04:36 UTC (rev 7607)
@@ -61,6 +61,8 @@
       <sourceFolder url="file://$MODULE_DIR$/mdb-cmp-tx-local/src" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/mdb-cmp-tx-not-supported/src" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/mdb-cmp-tx-required/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/mdb-message-selector/src" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/mdb-tx-send/src" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/servlet-ssl-example/src" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/servlet-transport/src" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/xarecovery/src" isTestSource="false" />

Modified: trunk/src/config/ra.xml
===================================================================
--- trunk/src/config/ra.xml	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/src/config/ra.xml	2009-07-27 09:04:36 UTC (rev 7607)
@@ -54,6 +54,12 @@
          <config-property-type>java.lang.String</config-property-type>
          <config-property-value>jbm.remoting.invm.serverid=0</config-property-value>
       </config-property>
+      <config-property>
+        <description>Use XA?</description>
+        <config-property-name>UseXA</config-property-name>
+        <config-property-type>java.lang.Boolean</config-property-type>
+        <config-property-value>true</config-property-value>
+      </config-property>
       <!-- <config-property>
         <description>Use A local Transaction instead of XA?</description>
         <config-property-name>UseLocalTx</config-property-name>

Modified: trunk/src/main/org/jboss/messaging/ra/JBMRAProperties.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMRAProperties.java	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/src/main/org/jboss/messaging/ra/JBMRAProperties.java	2009-07-27 09:04:36 UTC (rev 7607)
@@ -50,6 +50,9 @@
    /** The password */
    private String password;
 
+   /** Use XA */
+   private Boolean useXA;
+
    /** Use Local TX instead of XA */
    private Boolean localTx = false;
 
@@ -152,9 +155,37 @@
    }
 
    /**
-    * Use local tx instead of XA for
+    * Get the use XA flag
     * @return The value
     */
+   public Boolean getUseXA()
+   {
+      if (trace)
+      {
+         log.trace("getUseXA()");
+      }
+
+      return useXA;
+   }
+
+   /**
+    * Set the use XA flag
+    * @param xa The value
+    */
+   public void setUseXA(final Boolean xa)
+   {
+      if (trace)
+      {
+         log.trace("setUseXA(" + xa + ")");
+      }
+
+      useXA = xa;
+   }
+
+   /**
+    * Use XA for communication
+    * @return The value
+    */
    public boolean isUseXA()
    {
       if (trace)
@@ -162,8 +193,7 @@
          log.trace("isUseXA()");
       }
 
-      return localTx != null && localTx;
-
+      return useXA != null && useXA;
    }
    
 }

Modified: trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java	2009-07-27 09:04:36 UTC (rev 7607)
@@ -1212,6 +1212,36 @@
    }
 
    /**
+    * Get the use XA flag
+    *
+    * @return The value
+    */
+   public Boolean getUseXA()
+   {
+      if (trace)
+      {
+         log.trace("getUseXA()");
+      }
+
+      return raProperties.getUseXA();
+   }
+
+   /**
+    * Set the use XA flag
+    *
+    * @param xa The value
+    */
+   public void setUseXA(final Boolean xa)
+   {
+      if (trace)
+      {
+         log.trace("setUseXA(" + xa + ")");
+      }
+
+      raProperties.setUseXA(xa);
+   }
+
+   /**
     * Indicates whether some other object is "equal to" this one.
     *
     * @param obj Object with which to compare

Modified: trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivation.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivation.java	2009-07-24 11:28:15 UTC (rev 7606)
+++ trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivation.java	2009-07-27 09:04:36 UTC (rev 7607)
@@ -41,6 +41,7 @@
 import javax.naming.InitialContext;
 import javax.resource.ResourceException;
 import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.resource.spi.work.Work;
 import javax.resource.spi.work.WorkManager;
 import javax.transaction.TransactionManager;
 import java.lang.reflect.Method;
@@ -262,16 +263,8 @@
       {
          log.trace("start()");
       }
-
-      try
-      {
-         setup();
-      }
-      catch (Exception e)
-      {
-         throw new ResourceException("unable to start Activation", e);
-      }
       deliveryActive.set(true);
+      ra.getWorkManager().scheduleWork(new SetupActivation());
    }
 
    /**
@@ -501,4 +494,26 @@
       buffer.append(')');
       return buffer.toString();
    }
+
+   /**
+    * Handles the setup
+    */
+   private class SetupActivation implements Work
+   {
+      public void run()
+      {
+         try
+         {
+            setup();
+         }
+         catch (Throwable t)
+         {
+            log.error("Unabler to start activation ", t);
+         }
+      }
+
+      public void release()
+      {
+      }
+   }
 }




More information about the jboss-cvs-commits mailing list