[jboss-cvs] JBoss Messaging SVN: r6411 - in trunk: examples/jms and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Apr 12 12:07:58 EDT 2009
Author: gaohoward
Date: 2009-04-12 12:07:57 -0400 (Sun, 12 Apr 2009)
New Revision: 6411
Added:
trunk/examples/jms/xa-receive/
trunk/examples/jms/xa-receive/build.xml
trunk/examples/jms/xa-receive/readme.html
trunk/examples/jms/xa-receive/server0/
trunk/examples/jms/xa-receive/server0/client-jndi.properties
trunk/examples/jms/xa-receive/server0/jbm-configuration.xml
trunk/examples/jms/xa-receive/server0/jbm-jms.xml
trunk/examples/jms/xa-receive/server0/jbm-queues.xml
trunk/examples/jms/xa-receive/server0/jbm-security.xml
trunk/examples/jms/xa-receive/server0/jbm-standalone-beans.xml
trunk/examples/jms/xa-receive/src/
trunk/examples/jms/xa-receive/src/org/
trunk/examples/jms/xa-receive/src/org/jboss/
trunk/examples/jms/xa-receive/src/org/jboss/jms/
trunk/examples/jms/xa-receive/src/org/jboss/jms/example/
trunk/examples/jms/xa-receive/src/org/jboss/jms/example/XAReceiveExample.java
Modified:
trunk/.classpath
trunk/examples/jms/xa-send/readme.html
Log:
xa-receive example
Modified: trunk/.classpath
===================================================================
--- trunk/.classpath 2009-04-12 15:44:24 UTC (rev 6410)
+++ trunk/.classpath 2009-04-12 16:07:57 UTC (rev 6411)
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/.svn/**/*" kind="src" path="src/main"/>
+ <classpathentry kind="src" path="examples/jms/xa-receive/src"/>
<classpathentry kind="src" path="examples/jms/xa-send/src"/>
<classpathentry kind="src" path="build/src"/>
<classpathentry kind="src" path="tests/jms-tests/config"/>
Added: trunk/examples/jms/xa-receive/build.xml
===================================================================
--- trunk/examples/jms/xa-receive/build.xml (rev 0)
+++ trunk/examples/jms/xa-receive/build.xml 2009-04-12 16:07:57 UTC (rev 6411)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE project [
+ <!ENTITY libraries SYSTEM "../../../thirdparty/libraries.ent">
+ ]>
+
+<!-- =========================================================================================== -->
+<!-- -->
+<!-- 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 JMS Queue Example">
+
+ <import file="../common/build.xml"/>
+
+ <target name="run">
+ <antcall target="runExample">
+ <param name="example.classname" value="org.jboss.jms.example.XAReceiveExample"/>
+ </antcall>
+ </target>
+
+ <target name="runRemote">
+ <antcall target="runExample">
+ <param name="example.classname" value="org.jboss.jms.example.XAReceiveExample"/>
+ <param name="jbm.example.runServer" value="false"/>
+ </antcall>
+ </target>
+
+</project>
Added: trunk/examples/jms/xa-receive/readme.html
===================================================================
--- trunk/examples/jms/xa-receive/readme.html (rev 0)
+++ trunk/examples/jms/xa-receive/readme.html 2009-04-12 16:07:57 UTC (rev 6411)
@@ -0,0 +1,197 @@
+<html>
+ <head>
+ <title>JBoss Messaging JMS XA Send Example</title>
+ <link rel="stylesheet" type="text/css" href="../common/common.css">
+ </head>
+ <body>
+ <h1>JMS XA Send Example</h1>
+ <br>
+ <p>This example shows you how message receiving behaves in an XA transaction in JBoss Messaging. In an XA
+ Transaction, only if the associated XAResource are commited, will the messages be removed from the queue.
+ Otherwise, the messages maybe redelivered after rollback or during the XA recovery.</p>
+
+ <p>JBoss Messaging is JTA aware, meaning you can use JBoss Messaging in a XA transactional environment
+ and participate in XA transactions. It provides the javax.transaction.xa.XAResource interface for that
+ purpose. Users can get a XAConnectionFactory to create XAConnections and XASessions.</p>
+
+ <p>In this example we simulate a transaction manager to control the transactions. First we create an XASession
+ for receiiving and a normal session for sending. Then it starts a new xa transaction and enlist the receiving
+ XASession through its XAResource. We then send two words, 'hello' and 'world', receive them, and let the
+ transaction roll back. The received messages are cancelled back to the queue. Next we start
+ a new transaction with the same XAResource enlisted, but this time we commit the transaction after receiving the
+ messages. Then we check that no more messages are to be received.</p>
+ <br>
+ <h2>Example step-by-step</h2>
+ <p><i>To run the example, simply type <code>ant</code> from this 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>client-jndi.properties</code> file in the directory <code>../common/config</code></li>
+ <pre>
+ <code>InitialContext initialContext = getContext(0);</code>
+ </pre>
+
+ <li>We look-up the JMS queue object from JNDI</li>
+ <pre>
+ <code>Queue queue = (Queue) initialContext.lookup("/queue/exampleQueue");</code>
+ </pre>
+
+ <li>We perform a lookup on the XA Connection Factory</li>
+ <pre>
+ <code>XAConnectionFactory cf = (XAConnectionFactory) initialContext.lookup("/XAConnectionFactory");</code>
+ </pre>
+
+ <li>We create a JMS XAConnection</li>
+ <pre>
+ <code>connection = cf.createXAConnection();</code>
+ </pre>
+
+ <li>We Start the connection</li>
+ <pre>
+ <code>connection.start();</code>
+ </pre>
+
+ <li>We create a JMS XASession</li>
+ <pre>
+ <code>XASession xaSession = connection.createXASession();</code>
+ </pre>
+
+ <li>We create a normal session</li>
+ <pre>
+ <code>Session normalSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);</code>
+ </pre>
+
+ <li>We create a normal Message Consumer</li>
+ <pre>
+ <code>
+ MessageConsumer normalConsumer = normalSession.createConsumer(queue);
+ normalConsumer.setMessageListener(new SimpleMessageListener());
+ </code>
+ </pre>
+
+ <li>We get the JMS Session</li>
+ <pre>
+ <code>Session session = xaSession.getSession();</code>
+ </pre>
+
+ <li>We create a message producer</li>
+ <pre>
+ <code>MessageProducer producer = session.createProducer(queue);</code>
+ </pre>
+
+ <li>We create two Text Messages</li>
+ <pre>
+ <code>
+ TextMessage helloMessage = session.createTextMessage("hello");
+ TextMessage worldMessage = session.createTextMessage("world");
+ </code>
+ </pre>
+
+ <li>We create a transaction</li>
+ <pre>
+ <code>Xid xid1 = new XidImpl("xa-example1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());</code>
+ </pre>
+
+ <li>We get the JMS XAResource</li>
+ <pre>
+ <code>XAResource xaRes = xaSession.getXAResource();</code>
+ </pre>
+
+ <li>We begin the Transaction work</li>
+ <pre>
+ <code>xaRes.start(xid1, XAResource.TMNOFLAGS);</code>
+ </pre>
+
+ <li>We do work, sending two messages.</li>
+ <pre>
+ <code>
+ producer.send(helloMessage);
+ producer.send(worldMessage);
+ </code>
+ </pre>
+
+ <li>We check the result, it should receive none!</li>
+ <pre>
+ <code>checkNoMessageReceived();</code>
+ </pre>
+
+ <li>We stop the work</li>
+ <pre>
+ <code>xaRes.end(xid1, XAResource.TMSUCCESS);</code>
+ </pre>
+
+ <li>We prepare</li>
+ <pre>
+ <code>xaRes.prepare(xid1);</code>
+ </pre>
+
+ <li>We roll back the transaction </li>
+ <pre>
+ <code>xaRes.rollback(xid1);</code>
+ </pre>
+
+ <li>We check no messages should be received! </li>
+ <pre>
+ <code>checkNoMessageReceived();</code>
+ </pre>
+
+ <li>We create another transaction</li>
+ <pre>
+ <code>Xid xid2 = new XidImpl("xa-example2".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());</code>
+ </pre>
+
+ <li>We start the transaction</li>
+ <pre>
+ <code>xaRes.start(xid2, XAResource.TMNOFLAGS);</code>
+ </pre>
+
+ <li>We re-send those messages</li>
+ <pre>
+ <code>
+ producer.send(helloMessage);
+ producer.send(worldMessage);
+ </code>
+ </pre>
+
+ <li>We stop the work</li>
+ <pre>
+ <code>xaRes.end(xid2, XAResource.TMSUCCESS);</code>
+ </pre>
+
+ <li>We prepare</li>
+ <pre>
+ <code>xaRes.prepare(xid2);</code>
+ </pre>
+
+ <li>We check that no messages should be received at this moment</li>
+ <pre>
+ <code>checkNoMessageReceived();</code>
+ </pre>
+
+ <li>We commit!</li>
+ <pre>
+ <code>xaRes.commit(xid2, false);</code>
+ </pre>
+
+ <li>We check that all messages are received.</li>
+ <pre>
+ <code>checkAllMessageReceived();</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/jms/xa-receive/server0/client-jndi.properties
===================================================================
--- trunk/examples/jms/xa-receive/server0/client-jndi.properties (rev 0)
+++ trunk/examples/jms/xa-receive/server0/client-jndi.properties 2009-04-12 16:07:57 UTC (rev 6411)
@@ -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/jms/xa-receive/server0/jbm-configuration.xml
===================================================================
--- trunk/examples/jms/xa-receive/server0/jbm-configuration.xml (rev 0)
+++ trunk/examples/jms/xa-receive/server0/jbm-configuration.xml 2009-04-12 16:07:57 UTC (rev 6411)
@@ -0,0 +1,27 @@
+<deployment xmlns="urn:jboss:messaging"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-configuration.xsd">
+ <configuration>
+
+ <!-- Connectors -->
+
+ <connector name="netty-connector">
+ <factory-class>org.jboss.messaging.integration.transports.netty.NettyConnectorFactory</factory-class>
+ <param key="jbm.remoting.netty.port" value="5445" type="Integer"/>
+ </connector>
+
+ <!-- Acceptors -->
+
+ <acceptor name="netty-acceptor">
+ <factory-class>org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory</factory-class>
+ <param key="jbm.remoting.netty.port" value="5445" type="Integer"/>
+ </acceptor>
+
+
+ <!-- Other config -->
+
+ <journal-min-files>2</journal-min-files>
+
+ </configuration>
+
+</deployment>
Added: trunk/examples/jms/xa-receive/server0/jbm-jms.xml
===================================================================
--- trunk/examples/jms/xa-receive/server0/jbm-jms.xml (rev 0)
+++ trunk/examples/jms/xa-receive/server0/jbm-jms.xml 2009-04-12 16:07:57 UTC (rev 6411)
@@ -0,0 +1,18 @@
+<deployment xmlns="urn:jboss:messaging"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-jms.xsd ">
+ <!--the connection factory used by the example-->
+ <connection-factory name="ConnectionFactory">
+ <connector-ref connector-name="netty-connector"/>
+ <entry name="ConnectionFactory"/>
+ <entry name="XAConnectionFactory"/>
+ <entry name="java:/ConnectionFactory"/>
+ <entry name="java:/XAConnectionFactory"/>
+ </connection-factory>
+
+ <!--the queue used by the example-->
+ <queue name="exampleQueue">
+ <entry name="/queue/exampleQueue"/>
+ </queue>
+
+</deployment>
\ No newline at end of file
Added: trunk/examples/jms/xa-receive/server0/jbm-queues.xml
===================================================================
--- trunk/examples/jms/xa-receive/server0/jbm-queues.xml (rev 0)
+++ trunk/examples/jms/xa-receive/server0/jbm-queues.xml 2009-04-12 16:07:57 UTC (rev 6411)
@@ -0,0 +1,15 @@
+<settings xmlns="urn:jboss:messaging"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-queues.xsd ">
+
+ <!--security for example queue-->
+ <security match="jms.queue.exampleQueue">
+ <permission type="createDurableQueue" roles="guest"/>
+ <permission type="deleteDurableQueue" roles="guest"/>
+ <permission type="createTempQueue" roles="guest"/>
+ <permission type="deleteTempQueue" roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security>
+
+</settings>
Added: trunk/examples/jms/xa-receive/server0/jbm-security.xml
===================================================================
--- trunk/examples/jms/xa-receive/server0/jbm-security.xml (rev 0)
+++ trunk/examples/jms/xa-receive/server0/jbm-security.xml 2009-04-12 16:07:57 UTC (rev 6411)
@@ -0,0 +1,7 @@
+<deployment xmlns="urn:jboss:messaging" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-security.xsd ">
+ <!-- the default user. this is used where username is null-->
+ <defaultuser name="guest" password="guest">
+ <role name="guest"/>
+ </defaultuser>
+</deployment>
\ No newline at end of file
Added: trunk/examples/jms/xa-receive/server0/jbm-standalone-beans.xml
===================================================================
--- trunk/examples/jms/xa-receive/server0/jbm-standalone-beans.xml (rev 0)
+++ trunk/examples/jms/xa-receive/server0/jbm-standalone-beans.xml 2009-04-12 16:07:57 UTC (rev 6411)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Naming" class="org.jnp.server.NamingBeanImpl"/>
+
+ <!-- JNDI server. Disable this if you don't want JNDI -->
+ <bean name="JNDIServer" class="org.jnp.server.Main">
+ <property name="namingInfo">
+ <inject bean="Naming"/>
+ </property>
+ <property name="port">1099</property>
+ <property name="bindAddress">localhost</property>
+ <property name="rmiPort">1098</property>
+ <property name="rmiBindAddress">localhost</property>
+ </bean>
+
+ <!-- MBean server -->
+ <bean name="MBeanServer" class="javax.management.MBeanServer">
+ <constructor factoryClass="java.lang.management.ManagementFactory"
+ factoryMethod="getPlatformMBeanServer"/>
+ </bean>
+
+ <!-- The core configuration -->
+ <bean name="Configuration" class="org.jboss.messaging.core.config.impl.FileConfiguration"/>
+
+ <!-- The security manager -->
+ <bean name="JBMSecurityManager" class="org.jboss.messaging.core.security.impl.JBMSecurityManagerImpl">
+ <start ignored="true"/>
+ <stop ignored="true"/>
+ </bean>
+
+ <!-- The core server -->
+ <bean name="MessagingServer" class="org.jboss.messaging.core.server.impl.MessagingServerImpl">
+ <constructor>
+ <parameter>
+ <inject bean="Configuration"/>
+ </parameter>
+ <parameter>
+ <inject bean="MBeanServer"/>
+ </parameter>
+ <parameter>
+ <inject bean="JBMSecurityManager"/>
+ </parameter>
+ </constructor>
+ </bean>
+
+ <!-- The JMS server -->
+ <bean name="JMSServerManager" class="org.jboss.messaging.jms.server.impl.JMSServerManagerImpl">
+ <constructor>
+ <parameter>
+ <inject bean="MessagingServer"/>
+ </parameter>
+ </constructor>
+ </bean>
+
+</deployment>
Added: trunk/examples/jms/xa-receive/src/org/jboss/jms/example/XAReceiveExample.java
===================================================================
--- trunk/examples/jms/xa-receive/src/org/jboss/jms/example/XAReceiveExample.java (rev 0)
+++ trunk/examples/jms/xa-receive/src/org/jboss/jms/example/XAReceiveExample.java 2009-04-12 16:07:57 UTC (rev 6411)
@@ -0,0 +1,175 @@
+/*
+ * 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.jms.example;
+
+import java.util.ArrayList;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.jms.XAConnection;
+import javax.jms.XAConnectionFactory;
+import javax.jms.XASession;
+import javax.naming.InitialContext;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import org.jboss.messaging.core.transaction.impl.XidImpl;
+import org.jboss.messaging.utils.UUIDGenerator;
+
+/**
+ * A simple JMS example showing the usage of XA support in JMS.
+ *
+ * @author <a href="hgao at redhat.com">Howard Gao</a>
+ */
+public class XAReceiveExample extends JMSExample
+{
+ private volatile boolean result = true;
+ private ArrayList<String> receiveHolder = new ArrayList<String>();
+
+ public static void main(String[] args)
+ {
+ new XAReceiveExample().run(args);
+ }
+
+ public boolean runExample() throws Exception
+ {
+ XAConnection connection = null;
+ InitialContext initialContext = null;
+ try
+ {
+ //Step 1. Create an initial context to perform the JNDI lookup.
+ initialContext = getContext(0);
+
+ //Step 2. Lookup on the queue
+ Queue queue = (Queue) initialContext.lookup("/queue/exampleQueue");
+
+ //Step 3. Perform a lookup on the XA Connection Factory
+ XAConnectionFactory cf = (XAConnectionFactory) initialContext.lookup("/XAConnectionFactory");
+
+ //Step 4.Create a JMS XAConnection
+ connection = cf.createXAConnection();
+
+ //Step 5. Start the connection
+ connection.start();
+
+ //Step 6. Create a JMS XASession
+ XASession xaSession = connection.createXASession();
+
+ //Step 7. Create a normal session
+ Session normalSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ //Step 8. Create a normal Message Producer
+ MessageProducer normalProducer = normalSession.createProducer(queue);
+
+ //Step 9. Get the JMS Session
+ Session session = xaSession.getSession();
+
+ //Step 10. Create a message consumer
+ MessageConsumer xaConsumer = session.createConsumer(queue);
+
+ //Step 11. Create two Text Messages
+ TextMessage helloMessage = session.createTextMessage("hello");
+ TextMessage worldMessage = session.createTextMessage("world");
+
+ //Step 12. create a transaction
+ Xid xid1 = new XidImpl("xa-example1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
+
+ //Step 13. Get the JMS XAResource
+ XAResource xaRes = xaSession.getXAResource();
+
+ //Step 14. Begin the Transaction work
+ xaRes.start(xid1, XAResource.TMNOFLAGS);
+
+ //Step 12. Send two messages.
+ normalProducer.send(helloMessage);
+ normalProducer.send(worldMessage);
+
+ //Step 13. Receive the message
+ TextMessage rm1 = (TextMessage)xaConsumer.receive();
+ System.out.println("Message received: " + rm1.getText());
+ TextMessage rm2 = (TextMessage)xaConsumer.receive();
+ System.out.println("Message received: " + rm2.getText());
+
+ //Step 17. Stop the work
+ xaRes.end(xid1, XAResource.TMSUCCESS);
+
+ //Step 18. Prepare
+ xaRes.prepare(xid1);
+
+ //Step 19. Roll back the transaction
+ xaRes.rollback(xid1);
+
+ //Step 21. Create another transaction
+ Xid xid2 = new XidImpl("xa-example2".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
+
+ //Step 22. Start the transaction
+ xaRes.start(xid2, XAResource.TMNOFLAGS);
+
+ //Step 23. receive those messages again
+ rm1 = (TextMessage)xaConsumer.receive();
+ System.out.println("Message received again: " + rm1.getText());
+ rm2 = (TextMessage)xaConsumer.receive();
+ System.out.println("Message received again: " + rm2.getText());
+
+ //Step 24. Stop the work
+ xaRes.end(xid2, XAResource.TMSUCCESS);
+
+ //Step 25. Prepare
+ xaRes.prepare(xid2);
+
+ //Step 27. Commit!
+ xaRes.commit(xid2, true);
+
+ //Step 28. Check no more message is received.
+ TextMessage rm3 = (TextMessage)xaConsumer.receive(2000);
+ if (rm3 == null)
+ {
+ System.out.println("No message received after commit.");
+ }
+ else
+ {
+ result = false;
+ }
+
+ return result;
+ }
+ finally
+ {
+ //Step 29. Be sure to close our JMS resources!
+ if (initialContext != null)
+ {
+ initialContext.close();
+ }
+ if(connection != null)
+ {
+ connection.close();
+ }
+ }
+ }
+
+}
Modified: trunk/examples/jms/xa-send/readme.html
===================================================================
--- trunk/examples/jms/xa-send/readme.html 2009-04-12 15:44:24 UTC (rev 6410)
+++ trunk/examples/jms/xa-send/readme.html 2009-04-12 16:07:57 UTC (rev 6411)
@@ -6,7 +6,9 @@
<body>
<h1>JMS XA Send Example</h1>
<br>
- <p>This example shows you how message sending behaves in an XA transaction in JBoss Messaging.</p>
+ <p>This example shows you how message sending behaves in an XA transaction in JBoss Messaging. In an XA
+ Transaction, only if the associated XAResource are commited, will the messages be sent to the queue.
+ Otherwise, the messages to be sent will be discarded.</p>
<p>JBoss Messaging is JTA aware, meaning you can use JBoss Messaging in a XA transactional environment
and participate in XA transactions. It provides the javax.transaction.xa.XAResource interface for that
More information about the jboss-cvs-commits
mailing list