[jboss-cvs] JBoss Messaging SVN: r3049 - in trunk: tests/src/org/jboss/test/messaging/jms/clustering and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Aug 23 17:27:50 EDT 2007
Author: clebert.suconic at jboss.com
Date: 2007-08-23 17:27:50 -0400 (Thu, 23 Aug 2007)
New Revision: 3049
Modified:
trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-685
Modified: trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java 2007-08-23 19:06:42 UTC (rev 3048)
+++ trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java 2007-08-23 21:27:50 UTC (rev 3049)
@@ -106,10 +106,11 @@
// since an exception might be captured during an attempt, this has to be the first
// operation
attemptCount++;
+
+ int nextHopingServer = -1;
try
{
int failedNodeIDToServer = -1;
-
if (delegate == null)
{
if (failedNodeID != null && failedNodeID.intValue() >= 0)
@@ -117,6 +118,7 @@
//It's a reconnect after failover
delegate = getFailoverDelegateForNode(failedNodeID);
failedNodeIDToServer = failedNodeID.intValue();
+ nextHopingServer = delegate.getServerID();
}
else
{
@@ -223,8 +225,10 @@
}
catch (MessagingNetworkFailureException e)
{
+ // Setting up the next failover
+ failedNodeID = new Integer(nextHopingServer);
delegate = null;
- log.warn("Exception captured on createConnection... hopping to a new connection factory", e);
+ log.warn("Exception captured on createConnection... hopping to a new connection factory on server (" + failedNodeID + ")", e);
// Currently hardcoded
Thread.sleep(2000);
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java 2007-08-23 19:06:42 UTC (rev 3048)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java 2007-08-23 21:27:50 UTC (rev 3049)
@@ -39,6 +39,7 @@
import org.jboss.jms.client.FailoverEvent;
import org.jboss.jms.client.JBossConnection;
import org.jboss.jms.client.JBossSession;
+import org.jboss.jms.client.JBossConnectionFactory;
import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
import org.jboss.jms.client.delegate.ClientConnectionDelegate;
import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
@@ -691,6 +692,58 @@
}
}
+ /** testcase for http://jira.jboss.com/jira/browse/JBMESSAGING-1038 */
+ public void testHopping() throws Exception
+ {
+
+ JBossConnectionFactory localcf = (JBossConnectionFactory)ic[0].lookup("/ClusteredConnectionFactory");
+ ClientClusteredConnectionFactoryDelegate cfdelegate = (ClientClusteredConnectionFactoryDelegate)localcf.getDelegate();
+
+ ((ClientClusteredConnectionFactoryDelegate)cf.getDelegate()).closeCallback();
+
+ // After this, the CF won't get any callbacks
+ cfdelegate.closeCallback();
+
+ Connection conn = createConnectionOnServer(localcf, 1);
+
+ try
+ {
+
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = sess.createProducer(queue[1]);
+
+ MessageConsumer consumer = sess.createConsumer(queue[1]);
+
+ conn.start();
+
+ producer.send(sess.createTextMessage("sent before kill"));
+ TextMessage msg = (TextMessage)consumer.receive(2000);
+
+ assertNotNull(msg);
+ assertEquals("sent before kill", msg.getText());
+
+ ServerManagement.kill(2);
+ ServerManagement.kill(1);
+
+ // We need to guarantee we still have the old failover map (before the topology change for the test to be valid)
+ assertEquals(3, cfdelegate.getDelegates().length);
+
+ log.info("Sending Message");
+ producer.send(sess.createTextMessage("sent after kill"));
+ msg = (TextMessage) consumer.receive(2000);
+
+ assertNotNull(msg);
+ assertEquals("sent after kill", msg.getText());
+
+ assertEquals(0, getServerId(conn));
+ }
+ finally
+ {
+ conn.close();
+ }
+
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
More information about the jboss-cvs-commits
mailing list