[jboss-cvs] JBoss Messaging SVN: r7826 - in branches/Branch_JBossMessaging_1_4_0_SP3_CP08_JBMESSAGING_1734: docs/userguide/en/modules and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Sep 25 01:29:12 EDT 2009
Author: jbertram at redhat.com
Date: 2009-09-25 01:29:12 -0400 (Fri, 25 Sep 2009)
New Revision: 7826
Modified:
branches/Branch_JBossMessaging_1_4_0_SP3_CP08_JBMESSAGING_1734/build-messaging.xml
branches/Branch_JBossMessaging_1_4_0_SP3_CP08_JBMESSAGING_1734/docs/userguide/en/modules/introduction.xml
branches/Branch_JBossMessaging_1_4_0_SP3_CP08_JBMESSAGING_1734/src/main/org/jboss/jms/tx/ResourceManager.java
branches/Branch_JBossMessaging_1_4_0_SP3_CP08_JBMESSAGING_1734/tests/src/org/jboss/test/messaging/jms/XARecoveryTest.java
Log:
[JBPAPP-2827]
Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP08_JBMESSAGING_1734/build-messaging.xml
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP08_JBMESSAGING_1734/build-messaging.xml 2009-09-24 12:13:49 UTC (rev 7825)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP08_JBMESSAGING_1734/build-messaging.xml 2009-09-25 05:29:12 UTC (rev 7826)
@@ -53,7 +53,7 @@
<property name="messaging.version.minor" value="4"/>
<property name="messaging.version.revision" value="0"/>
<property name="messaging.version.incrementing" value="32"/>
- <property name="messaging.version.tag" value="SP3-CP08"/>
+ <property name="messaging.version.tag" value="SP3-CP08_JBMESSAGING-1734"/>
<property name="messaging.version.name" value="MaunaLoa"/>
<property name="messaging.version.cvstag" value="JBossMessaging_1_4_0_SP3_CP08"/>
<property name="module.name" value="messaging"/>
Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP08_JBMESSAGING_1734/docs/userguide/en/modules/introduction.xml
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP08_JBMESSAGING_1734/docs/userguide/en/modules/introduction.xml 2009-09-24 12:13:49 UTC (rev 7825)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP08_JBMESSAGING_1734/docs/userguide/en/modules/introduction.xml 2009-09-25 05:29:12 UTC (rev 7826)
@@ -199,4 +199,11 @@
identical, so they will require some simple adjustments to get them to work with JBoss Messaging. Also, the database data model is completely different, so don't attempt to use JBoss Messaging with a JBoss MQ data schema and vice-versa.
</important></para>
</section>
+
+ <section id="properties.retainOldxabehaviour">
+ <title>retain.oldxabehaviour</title>
+
+ <para>This system property controls what kind of exception a JMS XAResource throws when the prepare is called after the connection is broken. If this property is not defined, an XAException with XA_RBCOMMFAIL error code will be thrown. If this propertie is defined, an XAException with XA_RETRY error code will be thrown instead. JBM by default doesn't define this property.</para>
+ </section>
+ </section>
</chapter>
Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP08_JBMESSAGING_1734/src/main/org/jboss/jms/tx/ResourceManager.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP08_JBMESSAGING_1734/src/main/org/jboss/jms/tx/ResourceManager.java 2009-09-24 12:13:49 UTC (rev 7825)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP08_JBMESSAGING_1734/src/main/org/jboss/jms/tx/ResourceManager.java 2009-09-25 05:29:12 UTC (rev 7826)
@@ -387,7 +387,7 @@
request.xid = xid;
- sendTransactionXA(request, connection);
+ sendTransactionXA(request, connection);
}
if (tx != null)
@@ -681,12 +681,28 @@
//the server has been fixed.
//(In some cases it will not be possible to fix so the user will have to manually resolve the tx)
-
- //Therefore we throw XA_RETRY
- //Note we DO NOT throw XAER_RMFAIL or XAER_RMERR since both if these will cause the Arjuna
- //tx mgr NOT to retry and the transaction will have to be resolve manually.
-
- throw new MessagingXAException(XAException.XA_RETRY, "A Throwable was caught in sending the transaction", t);
+ if (trace) { log.trace( "sendTransaction failure for phase: " + request.getRequestType() ); }
+ if (request.getRequestType() == TransactionRequest.TWO_PHASE_PREPARE_REQUEST)
+ {
+
+ String oldBehaviour = System.getProperty("retain.oldxabehaviour");
+ if (oldBehaviour != null)
+ {
+ //Therefore we throw XA_RETRY
+ //Note we DO NOT throw XAER_RMFAIL or XAER_RMERR since both if these will cause the Arjuna
+ //tx mgr NOT to retry and the transaction will have to be resolve manually.
+ throw new MessagingXAException(XAException.XA_RETRY, "A Throwable was caught in sending the transaction", t);
+ }
+ else
+ {
+ //https://jira.jboss.org/jira/browse/JBMESSAGING-1734
+ throw new MessagingXAException(XAException.XA_RBCOMMFAIL, "A Throwable was caught in sending the transaction", t);
+ }
+ }
+ else
+ {
+ throw new MessagingXAException(XAException.XA_RETRY, "A Throwable was caught in sending the transaction", t);
+ }
}
}
Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP08_JBMESSAGING_1734/tests/src/org/jboss/test/messaging/jms/XARecoveryTest.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP08_JBMESSAGING_1734/tests/src/org/jboss/test/messaging/jms/XARecoveryTest.java 2009-09-24 12:13:49 UTC (rev 7825)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP08_JBMESSAGING_1734/tests/src/org/jboss/test/messaging/jms/XARecoveryTest.java 2009-09-25 05:29:12 UTC (rev 7826)
@@ -22,6 +22,7 @@
package org.jboss.test.messaging.jms;
import javax.jms.*;
+import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
@@ -3759,5 +3760,300 @@
}
}
+ //https://jira.jboss.org/jira/browse/JBMESSAGING-1734
+ public void testTxPrepareAfterConnFailure_XACompliant() throws Exception
+ {
+ log.trace("starting testTxPrepareAfterConnFailure_XACompliant");
+
+ Connection conn1 = null;
+
+ XAConnection conn2 = null;
+
+ XAConnection conn3 = null;
+
+ try
+ {
+ //First send a message to the queue
+ conn1 = cf.createConnection();
+
+ Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sess1.createProducer(queue4);
+ prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ TextMessage tm1 = sess1.createTextMessage("tm1");
+
+ prod.send(tm1);
+
+ conn2 = cf.createXAConnection();
+
+ XASession sess2 = conn2.createXASession();
+
+ XAResource res1 = sess2.getXAResource();
+
+ //Pretend to be a transaction manager by interacting through the XAResources
+ Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());
+
+ res1.start(xid1, XAResource.TMNOFLAGS);
+
+ MessageConsumer cons = sess2.createConsumer(queue4);
+
+ conn2.start();
+
+ //Consume the message
+
+ TextMessage rm1 = (TextMessage)cons.receive(1000);
+
+ assertNotNull(rm1);
+
+ assertEquals(tm1.getText(), rm1.getText());
+
+ res1.end(xid1, XAResource.TMSUCCESS);
+
+
+ conn1.close();
+
+ conn2.close();
+
+ conn1 = null;
+
+ conn2 = null;
+
+ // Now "crash" the server
+ ServerManagement.stopServerPeer();
+
+ //prepare the tx
+ try
+ {
+ res1.prepare(xid1);
+ fail("Expected exception not received.");
+ }
+ catch (XAException e)
+ {
+ log.info("Got exception in prepare: " + e.errorCode);
+ assertEquals(XAException.XA_RBCOMMFAIL, e.errorCode);
+ }
+
+ //now start
+ ServerManagement.startServerPeer();
+
+ deployAndLookupAdministeredObjects();
+
+ //Now recover
+
+ conn3 = cf.createXAConnection();
+
+ XASession sess3 = conn3.createXASession();
+
+ XAResource res3 = sess3.getXAResource();
+
+ Xid[] xids = res3.recover(XAResource.TMSTARTRSCAN);
+ assertEquals(0, xids.length);
+
+ //The message should be acknowldged
+ conn3.close();
+
+ conn1 = cf.createConnection();
+
+ sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons1 = sess1.createConsumer(queue4);
+
+ conn1.start();
+
+ Message m = cons1.receive(1000);
+
+ assertNull(m);
+
+ }
+ finally
+ {
+ if (conn1 != null)
+ {
+ try
+ {
+ conn1.close();
+ }
+ catch (Exception e)
+ {
+ //Ignore
+ }
+ }
+
+ if (conn2 != null)
+ {
+ try
+ {
+ conn2.close();
+ }
+ catch (Exception e)
+ {
+ //Ignore
+ }
+ }
+
+ if (conn3 != null)
+ {
+ try
+ {
+ conn3.close();
+ }
+ catch (Exception e)
+ {
+ //Ignore
+ }
+ }
+ }
+ }
+
+ //https://jira.jboss.org/jira/browse/JBMESSAGING-1734
+ public void testTxPrepareAfterConnFailure_XACompliant2() throws Exception
+ {
+ log.trace("starting testTxPrepareAfterConnFailure_XACompliant");
+
+ Connection conn1 = null;
+
+ XAConnection conn2 = null;
+
+ XAConnection conn3 = null;
+
+ System.setProperty("retain.oldxabehaviour", "");
+
+ try
+ {
+ //First send a message to the queue
+ conn1 = cf.createConnection();
+
+ Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sess1.createProducer(queue4);
+ prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ TextMessage tm1 = sess1.createTextMessage("tm1");
+
+ prod.send(tm1);
+
+ conn2 = cf.createXAConnection();
+
+ XASession sess2 = conn2.createXASession();
+
+ XAResource res1 = sess2.getXAResource();
+
+ //Pretend to be a transaction manager by interacting through the XAResources
+ Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());
+
+ res1.start(xid1, XAResource.TMNOFLAGS);
+
+ MessageConsumer cons = sess2.createConsumer(queue4);
+
+ conn2.start();
+
+ //Consume the message
+
+ TextMessage rm1 = (TextMessage)cons.receive(1000);
+
+ assertNotNull(rm1);
+
+ assertEquals(tm1.getText(), rm1.getText());
+
+ res1.end(xid1, XAResource.TMSUCCESS);
+
+
+ conn1.close();
+
+ conn2.close();
+
+ conn1 = null;
+
+ conn2 = null;
+
+ // Now "crash" the server
+ ServerManagement.stopServerPeer();
+
+ //prepare the tx
+ try
+ {
+ res1.prepare(xid1);
+ fail("Expected exception not received.");
+ }
+ catch (XAException e)
+ {
+ log.info("Got exception in prepare: " + e.errorCode);
+ assertEquals(XAException.XA_RETRY, e.errorCode);
+ }
+
+ //now start
+ ServerManagement.startServerPeer();
+
+ deployAndLookupAdministeredObjects();
+
+ //Now recover
+
+ conn3 = cf.createXAConnection();
+
+ XASession sess3 = conn3.createXASession();
+
+ XAResource res3 = sess3.getXAResource();
+
+ Xid[] xids = res3.recover(XAResource.TMSTARTRSCAN);
+ assertEquals(0, xids.length);
+
+ //The message should be acknowldged
+ conn3.close();
+
+ conn1 = cf.createConnection();
+
+ sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons1 = sess1.createConsumer(queue4);
+
+ conn1.start();
+
+ Message m = cons1.receive(1000);
+
+ assertNull(m);
+
+ }
+ finally
+ {
+ if (conn1 != null)
+ {
+ try
+ {
+ conn1.close();
+ }
+ catch (Exception e)
+ {
+ //Ignore
+ }
+ }
+
+ if (conn2 != null)
+ {
+ try
+ {
+ conn2.close();
+ }
+ catch (Exception e)
+ {
+ //Ignore
+ }
+ }
+
+ if (conn3 != null)
+ {
+ try
+ {
+ conn3.close();
+ }
+ catch (Exception e)
+ {
+ //Ignore
+ }
+ }
+
+ System.clearProperty("retain.oldxabehaviour");
+
+ }
+ }
+
}
More information about the jboss-cvs-commits
mailing list