[hornetq-commits] JBoss hornetq SVN: r10338 - in branches/Branch_2_2_EAP: src/main/org/hornetq/jms/client and 3 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Mar 15 07:38:31 EDT 2011


Author: ataylor
Date: 2011-03-15 07:38:30 -0400 (Tue, 15 Mar 2011)
New Revision: 10338

Modified:
   branches/Branch_2_2_EAP/docs/user-manual/en/ha.xml
   branches/Branch_2_2_EAP/src/main/org/hornetq/jms/client/HornetQConnection.java
   branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAManagedConnection.java
   branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
   branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/jms/cluster/JMSReconnectTest.java
Log:
https://issues.jboss.org/browse/HORNETQ-653

Modified: branches/Branch_2_2_EAP/docs/user-manual/en/ha.xml
===================================================================
--- branches/Branch_2_2_EAP/docs/user-manual/en/ha.xml	2011-03-15 11:18:33 UTC (rev 10337)
+++ branches/Branch_2_2_EAP/docs/user-manual/en/ha.xml	2011-03-15 11:38:30 UTC (rev 10338)
@@ -302,7 +302,37 @@
             <para>Any ExceptionListener or SessionFailureListener instance will always be called by
                 HornetQ on event of connection failure, <emphasis role="bold"
                     >irrespective</emphasis> of whether the connection was successfully failed over,
-                reconnected or reattached.</para>
+                reconnected or reattached, however you can find out if reconnect or reattach has happened
+            by either the <literal>failedOver</literal> flag passed in on the <literal>connectionFailed</literal>
+               on <literal>SessionfailureListener</literal> or by inspecting the error code on the
+               <literal>javax.jms.JMSException</literal> which will be one of the following:</para>
+           <table frame="topbot" border="2">
+              <title>JMSException error codes</title>
+              <tgroup cols="2">
+                 <colspec colname="c1" colnum="1"/>
+                 <colspec colname="c2" colnum="2"/>
+                 <thead>
+                    <row>
+                       <entry>error code</entry>
+                       <entry>Description</entry>
+                    </row>
+                 </thead>
+                 <tbody>
+                    <row>
+                       <entry>FAILOVER</entry>
+                       <entry>
+                          Failover has occurred and we have successfully reattached or reconnected.
+                       </entry>
+                    </row>
+                    <row>
+                       <entry>DISCONNECT</entry>
+                       <entry>
+                          No failover has occurred and we are disconnected.
+                       </entry>
+                    </row>
+                 </tbody>
+              </tgroup>
+           </table>
         </section>
         <section>
             <title>Application-Level Failover</title>

Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/jms/client/HornetQConnection.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/jms/client/HornetQConnection.java	2011-03-15 11:18:33 UTC (rev 10337)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/jms/client/HornetQConnection.java	2011-03-15 11:38:30 UTC (rev 10338)
@@ -69,6 +69,10 @@
 
    public static final int TYPE_TOPIC_CONNECTION = 2;
 
+   public static final String EXCEPTION_FAILOVER = "FAILOVER";
+
+   public static final String EXCEPTION_DISCONNECT = "DISCONNECT";
+
    public static final SimpleString CONNECTION_ID_PROPERTY_NAME = new SimpleString("__HQ_CID");
 
    // Static ---------------------------------------------------------------------------------------
@@ -628,7 +632,7 @@
 
          HornetQConnection conn = connectionRef.get();
 
-         if (conn != null && ! failedOver)
+         if (conn != null)
          {
             try
             {
@@ -636,7 +640,7 @@
 
                if (exceptionListener != null)
                {
-                  final JMSException je = new JMSException(me.toString());
+                  final JMSException je = new JMSException(me.toString(), failedOver?EXCEPTION_FAILOVER: EXCEPTION_DISCONNECT);
 
                   je.initCause(me);
 

Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAManagedConnection.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAManagedConnection.java	2011-03-15 11:18:33 UTC (rev 10337)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAManagedConnection.java	2011-03-15 11:38:30 UTC (rev 10338)
@@ -51,6 +51,7 @@
 import javax.transaction.xa.XAResource;
 
 import org.hornetq.core.logging.Logger;
+import org.hornetq.jms.client.HornetQConnection;
 
 /**
  * The managed connection
@@ -555,6 +556,10 @@
     */
    public void onException(final JMSException exception)
    {
+      if(HornetQConnection.EXCEPTION_FAILOVER.equals(exception.getErrorCode()))
+      {
+         return;
+      }
       if (HornetQRAManagedConnection.trace)
       {
          HornetQRAManagedConnection.log.trace("onException(" + exception + ")");

Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java	2011-03-15 11:18:33 UTC (rev 10337)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java	2011-03-15 11:38:30 UTC (rev 10338)
@@ -262,6 +262,7 @@
             fail("backup server never started");
          }
       }
+      System.out.println("sf.getBackupConnector() = " + sf.getBackupConnector());
    }
 
    protected void waitForBackup(long seconds)

Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/jms/cluster/JMSReconnectTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/jms/cluster/JMSReconnectTest.java	2011-03-15 11:18:33 UTC (rev 10337)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/jms/cluster/JMSReconnectTest.java	2011-03-15 11:38:30 UTC (rev 10338)
@@ -169,10 +169,10 @@
       conn.close();
 
 
-// TODO - https://issues.jboss.org/browse/HORNETQ-653
-//      Assert.assertNotNull(listener.e);
-//
-//      Assert.assertTrue(me == listener.e.getCause());
+
+      Assert.assertNotNull(listener.e);
+
+      Assert.assertTrue(me == listener.e.getCause());
    }
    
    public void testReconnectSameNodeServerRestartedWithNonDurableSub() throws Exception
@@ -257,8 +257,7 @@
 
       conn.close();
 
-      // TODO - https://issues.jboss.org/browse/HORNETQ-653
-      //Assert.assertNotNull(listener.e);
+      Assert.assertNotNull(listener.e);
    }
    
    //If the server is shutdown after a non durable sub is created, then close on the connection should proceed normally



More information about the hornetq-commits mailing list