[jboss-cvs] JBoss Messaging SVN: r1726 - in branches/Branch_Client_Failover_Experiment: src/main/org/jboss/jms/client/container tests/src/org/jboss/test/messaging/jms/clustering tests/src/org/jboss/test/messaging/jms/clustering/base
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Dec 8 07:44:58 EST 2006
Author: timfox
Date: 2006-12-08 07:44:52 -0500 (Fri, 08 Dec 2006)
New Revision: 1726
Modified:
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/container/HAAspect.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ManualClusteringTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/SimpleClusteringTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java
Log:
tweaks
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/container/HAAspect.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/container/HAAspect.java 2006-12-08 12:15:43 UTC (rev 1725)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/container/HAAspect.java 2006-12-08 12:44:52 UTC (rev 1726)
@@ -25,7 +25,9 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+
import javax.jms.JMSException;
+
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodInvocation;
import org.jboss.aop.metadata.SimpleMetaData;
@@ -437,6 +439,9 @@
{
try
{
+ log.info("handleConnectionException: ", throwable);
+
+
log.info("Caught connection exception for connection: " + connection);
handleFailure(connection);
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java 2006-12-08 12:15:43 UTC (rev 1725)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java 2006-12-08 12:44:52 UTC (rev 1726)
@@ -70,7 +70,7 @@
{
try
{
- JBossConnectionFactory factory = (JBossConnectionFactory )ic1.lookup("/ConnectionFactory");
+ JBossConnectionFactory factory = (JBossConnectionFactory )ic2.lookup("/ConnectionFactory");
ClusteredClientConnectionFactoryDelegate delegate =
(ClusteredClientConnectionFactoryDelegate)factory.getDelegate();
log.info ("number of delegates = " + delegate.getDelegates().length);
@@ -99,7 +99,7 @@
ServerManagement.log(ServerManagement.INFO,"##### Looking up ConnectionFactory at testConnectionFactoryConnect");
- factory = (JBossConnectionFactory )ic1.lookup("/ConnectionFactory");
+ factory = (JBossConnectionFactory )ic2.lookup("/ConnectionFactory");
delegate = (ClusteredClientConnectionFactoryDelegate)factory.getDelegate();
assertEquals(2, ServerManagement.getServer(0).getNumberOfNodesOnCluster());
@@ -121,14 +121,14 @@
log.info("++testTopicSubscriber");
- JBossConnectionFactory jbcf1 = (JBossConnectionFactory)cf1;
+ JBossConnectionFactory jbcf1 = (JBossConnectionFactory)cf;
assertTrue(jbcf1.getDelegate() instanceof ClusteredClientConnectionFactoryDelegate);
log.info(">>Lookup Queue");
- Destination destination = (Destination) ic1.lookup("topic/testDistributedTopic");
+ Destination destination = (Destination) ic2.lookup("topic/testDistributedTopic");
log.info("Creating connection server1");
- JBossConnection conn = (JBossConnection) cf1.createConnection();
+ JBossConnection conn = (JBossConnection) cf.createConnection();
conn.setClientID("testClient");
conn.start();
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ManualClusteringTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ManualClusteringTest.java 2006-12-08 12:15:43 UTC (rev 1725)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ManualClusteringTest.java 2006-12-08 12:44:52 UTC (rev 1726)
@@ -138,32 +138,7 @@
{
super.tearDown();
}
-
- private void checkConnectionsDifferentServers(Connection conn, Connection conn1, Connection conn2)
- {
- ConnectionState state = (ConnectionState)(((DelegateSupport)((JBossConnection)conn).getDelegate()).getState());
-
- ConnectionState state1 = (ConnectionState)(((DelegateSupport)((JBossConnection)conn1).getDelegate()).getState());
-
- ConnectionState state2 = (ConnectionState)(((DelegateSupport)((JBossConnection)conn2).getDelegate()).getState());
-
- int serverID = state.getServerID();
-
- int serverID1 = state1.getServerID();
-
- int serverID2 = state2.getServerID();
-
- log.info("Server id:" + serverID);
-
- log.info("Server id1:" + serverID1);
-
- log.info("Server id2:" + serverID2);
-
-
- assertTrue(serverID != serverID1);
-
- assertTrue(serverID1 != serverID2);
- }
+
/*
* Create a consumer on each queue on each node.
@@ -172,41 +147,41 @@
*/
protected void clusteredQueueLocalConsumer(boolean persistent) throws Exception
{
- Connection conn = null;
Connection conn1 = null;
Connection conn2 = null;
+ Connection conn3 = null;
try
{
//This will create 3 different connection on 3 different nodes, since
//the cf is clustered
- conn = cf.createConnection();
conn1 = cf.createConnection();
conn2 = cf.createConnection();
+ conn3 = cf.createConnection();
log.info("Created connections");
- checkConnectionsDifferentServers(conn, conn1, conn2);
+ checkConnectionsDifferentServers(conn1, conn2, conn3);
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
log.info("Created sessions");
- MessageConsumer cons = sess.createConsumer(queue);
MessageConsumer cons1 = sess1.createConsumer(queue1);
MessageConsumer cons2 = sess2.createConsumer(queue2);
+ MessageConsumer cons3 = sess3.createConsumer(queue3);
log.info("Created consumers");
- conn.start();
conn1.start();
conn2.start();
+ conn3.start();
// Send at node 0
- MessageProducer prod = sess.createProducer(queue);
+ MessageProducer prod = sess1.createProducer(queue1);
prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
@@ -214,7 +189,7 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = sess.createTextMessage("message" + i);
+ TextMessage tm = sess1.createTextMessage("message" + i);
prod.send(tm);
}
@@ -223,90 +198,83 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons.receive(1000);
+ TextMessage tm = (TextMessage)cons1.receive(1000);
assertNotNull(tm);
- log.info("1 GOT MESSAGE: " + tm.getText());
-
assertEquals("message" + i, tm.getText());
}
- Message m = cons1.receive(2000);
+ Message m = cons2.receive(2000);
assertNull(m);
- m = cons2.receive(2000);
+ m = cons3.receive(2000);
assertNull(m);
// Send at node 1
- MessageProducer prod1 = sess1.createProducer(queue1);
+ MessageProducer prod1 = sess2.createProducer(queue2);
prod1.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = sess1.createTextMessage("message" + i);
+ TextMessage tm = sess2.createTextMessage("message" + i);
prod1.send(tm);
}
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons1.receive(1000);
+ TextMessage tm = (TextMessage)cons2.receive(1000);
assertNotNull(tm);
assertEquals("message" + i, tm.getText());
}
- m = cons.receive(2000);
+ m = cons1.receive(2000);
assertNull(m);
- m = cons2.receive(2000);
+ m = cons3.receive(2000);
assertNull(m);
// Send at node 2
- MessageProducer prod2 = sess2.createProducer(queue2);
+ MessageProducer prod2 = sess3.createProducer(queue3);
prod2.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = sess2.createTextMessage("message" + i);
+ TextMessage tm = sess3.createTextMessage("message" + i);
prod2.send(tm);
}
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons2.receive(1000);
+ TextMessage tm = (TextMessage)cons3.receive(1000);
assertNotNull(tm);
assertEquals("message" + i, tm.getText());
}
- m = cons.receive(2000);
+ m = cons1.receive(2000);
assertNull(m);
- m = cons1.receive(2000);
+ m = cons2.receive(2000);
assertNull(m);
}
finally
{
- if (conn != null)
- {
- conn.close();
- }
-
if (conn1 != null)
{
conn1.close();
@@ -316,6 +284,11 @@
{
conn2.close();
}
+
+ if (conn3 != null)
+ {
+ conn3.close();
+ }
}
}
@@ -327,40 +300,40 @@
*/
private void clusteredTopicNonDurable(boolean persistent) throws Exception
{
- Connection conn = null;
Connection conn1 = null;
Connection conn2 = null;
+ Connection conn3 = null;
try
{
//This will create 3 different connection on 3 different nodes, since
//the cf is clustered
- conn = cf.createConnection();
conn1 = cf.createConnection();
conn2 = cf.createConnection();
+ conn3 = cf.createConnection();
log.info("Created connections");
- checkConnectionsDifferentServers(conn, conn1, conn2);
+ checkConnectionsDifferentServers(conn1, conn2, conn3);
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sess.createConsumer(topic);
MessageConsumer cons1 = sess1.createConsumer(topic1);
MessageConsumer cons2 = sess2.createConsumer(topic2);
+ MessageConsumer cons3 = sess3.createConsumer(topic3);
- MessageConsumer cons3 = sess.createConsumer(topic);
-
MessageConsumer cons4 = sess1.createConsumer(topic1);
- conn.start();
+ MessageConsumer cons5 = sess2.createConsumer(topic2);
+
conn1.start();
conn2.start();
+ conn3.start();
// Send at node 0
- MessageProducer prod = sess.createProducer(topic);
+ MessageProducer prod = sess1.createProducer(topic1);
prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
@@ -368,14 +341,14 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = sess.createTextMessage("message" + i);
+ TextMessage tm = sess1.createTextMessage("message" + i);
prod.send(tm);
}
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons.receive(1000);
+ TextMessage tm = (TextMessage)cons1.receive(1000);
assertNotNull(tm);
@@ -384,7 +357,7 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons1.receive(1000);
+ TextMessage tm = (TextMessage)cons2.receive(1000);
assertNotNull(tm);
@@ -393,7 +366,7 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons2.receive(1000);
+ TextMessage tm = (TextMessage)cons3.receive(1000);
assertNotNull(tm);
@@ -402,7 +375,7 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons3.receive(1000);
+ TextMessage tm = (TextMessage)cons4.receive(1000);
assertNotNull(tm);
@@ -411,7 +384,7 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons4.receive(1000);
+ TextMessage tm = (TextMessage)cons5.receive(1000);
assertNotNull(tm);
@@ -420,11 +393,6 @@
}
finally
{
- if (conn != null)
- {
- conn.close();
- }
-
if (conn1 != null)
{
conn1.close();
@@ -434,6 +402,11 @@
{
conn2.close();
}
+
+ if (conn3 != null)
+ {
+ conn3.close();
+ }
}
}
@@ -444,41 +417,41 @@
*/
private void clusteredTopicNonDurableWithSelectors(boolean persistent) throws Exception
{
- Connection conn = null;
Connection conn1 = null;
Connection conn2 = null;
+ Connection conn3 = null;
try
{
//This will create 3 different connection on 3 different nodes, since
//the cf is clustered
- conn = cf.createConnection();
conn1 = cf.createConnection();
conn2 = cf.createConnection();
+ conn3 = cf.createConnection();
log.info("Created connections");
- checkConnectionsDifferentServers(conn, conn1, conn2);
+ checkConnectionsDifferentServers(conn1, conn2, conn3);
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sess.createConsumer(topic);
MessageConsumer cons1 = sess1.createConsumer(topic1);
MessageConsumer cons2 = sess2.createConsumer(topic2);
+ MessageConsumer cons3 = sess3.createConsumer(topic3);
- MessageConsumer cons3 = sess.createConsumer(topic, "COLOUR='red'");
+ MessageConsumer cons4 = sess1.createConsumer(topic1, "COLOUR='red'");
- MessageConsumer cons4 = sess1.createConsumer(topic1, "COLOUR='blue'");
+ MessageConsumer cons5 = sess2.createConsumer(topic2, "COLOUR='blue'");
- conn.start();
conn1.start();
conn2.start();
+ conn3.start();
// Send at node 0
- MessageProducer prod = sess.createProducer(topic);
+ MessageProducer prod = sess1.createProducer(topic1);
prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
@@ -486,7 +459,7 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = sess.createTextMessage("message" + i);
+ TextMessage tm = sess1.createTextMessage("message" + i);
int c = i % 3;
if (c == 0)
@@ -503,7 +476,7 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons.receive(1000);
+ TextMessage tm = (TextMessage)cons1.receive(1000);
assertNotNull(tm);
@@ -512,7 +485,7 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons1.receive(1000);
+ TextMessage tm = (TextMessage)cons2.receive(1000);
assertNotNull(tm);
@@ -521,7 +494,7 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons2.receive(1000);
+ TextMessage tm = (TextMessage)cons3.receive(1000);
assertNotNull(tm);
@@ -534,7 +507,7 @@
if (c == 0)
{
- TextMessage tm = (TextMessage)cons3.receive(1000);
+ TextMessage tm = (TextMessage)cons4.receive(1000);
assertNotNull(tm);
@@ -548,7 +521,7 @@
if (c == 1)
{
- TextMessage tm = (TextMessage)cons4.receive(1000);
+ TextMessage tm = (TextMessage)cons5.receive(1000);
assertNotNull(tm);
@@ -558,11 +531,6 @@
}
finally
{
- if (conn != null)
- {
- conn.close();
- }
-
if (conn1 != null)
{
conn1.close();
@@ -572,6 +540,11 @@
{
conn2.close();
}
+
+ if (conn3 != null)
+ {
+ conn3.close();
+ }
}
}
@@ -585,68 +558,68 @@
*/
private void clusteredTopicDurable(boolean persistent) throws Exception
{
- Connection conn = null;
Connection conn1 = null;
Connection conn2 = null;
+ Connection conn3 = null;
try
{
//This will create 3 different connection on 3 different nodes, since
//the cf is clustered
- conn = cf.createConnection();
conn1 = cf.createConnection();
conn2 = cf.createConnection();
+ conn3 = cf.createConnection();
log.info("Created connections");
- checkConnectionsDifferentServers(conn, conn1, conn2);
+ checkConnectionsDifferentServers(conn1, conn2, conn3);
- conn.setClientID("wib1");
conn1.setClientID("wib1");
conn2.setClientID("wib1");
+ conn3.setClientID("wib1");
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
try
{
- sess.unsubscribe("sub");
+ sess1.unsubscribe("sub");
}
catch (Exception ignore) {}
try
{
- sess1.unsubscribe("sub1");
+ sess2.unsubscribe("sub1");
}
catch (Exception ignore) {}
try
{
- sess2.unsubscribe("sub2");
+ sess3.unsubscribe("sub2");
}
catch (Exception ignore) {}
try
{
- sess.unsubscribe("sub3");
+ sess1.unsubscribe("sub3");
}
catch (Exception ignore) {}
try
{
- sess1.unsubscribe("sub4");
+ sess2.unsubscribe("sub4");
}
catch (Exception ignore) {}
- MessageConsumer cons = sess.createDurableSubscriber(topic, "sub");
- MessageConsumer cons1 = sess1.createDurableSubscriber(topic1, "sub1");
- MessageConsumer cons2 = sess2.createDurableSubscriber(topic2, "sub2");
- MessageConsumer cons3 = sess.createDurableSubscriber(topic, "sub3");
- MessageConsumer cons4 = sess1.createDurableSubscriber(topic1, "sub4");
+ MessageConsumer cons1 = sess1.createDurableSubscriber(topic1, "sub");
+ MessageConsumer cons2 = sess2.createDurableSubscriber(topic2, "sub1");
+ MessageConsumer cons3 = sess3.createDurableSubscriber(topic3, "sub2");
+ MessageConsumer cons4 = sess1.createDurableSubscriber(topic1, "sub3");
+ MessageConsumer cons5 = sess2.createDurableSubscriber(topic2, "sub4");
- conn.start();
conn1.start();
conn2.start();
+ conn3.start();
// Send at node 0
- MessageProducer prod = sess.createProducer(topic);
+ MessageProducer prod = sess1.createProducer(topic1);
prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
@@ -654,14 +627,14 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = sess1.createTextMessage("message" + i);
+ TextMessage tm = sess2.createTextMessage("message" + i);
prod.send(tm);
}
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons.receive(1000);
+ TextMessage tm = (TextMessage)cons1.receive(1000);
assertNotNull(tm);
@@ -670,7 +643,7 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons1.receive(1000);
+ TextMessage tm = (TextMessage)cons2.receive(1000);
assertNotNull(tm);
@@ -679,7 +652,7 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons2.receive(1000);
+ TextMessage tm = (TextMessage)cons3.receive(1000);
assertNotNull(tm);
@@ -688,7 +661,7 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons3.receive(1000);
+ TextMessage tm = (TextMessage)cons4.receive(1000);
assertNotNull(tm);
@@ -697,33 +670,28 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons4.receive(1000);
+ TextMessage tm = (TextMessage)cons5.receive(1000);
assertNotNull(tm);
assertEquals("message" + i, tm.getText());
}
- cons.close();
cons1.close();
cons2.close();
cons3.close();
cons4.close();
+ cons5.close();
- sess.unsubscribe("sub");
- sess1.unsubscribe("sub1");
- sess2.unsubscribe("sub2");
- sess.unsubscribe("sub3");
- sess1.unsubscribe("sub4");
+ sess1.unsubscribe("sub");
+ sess2.unsubscribe("sub1");
+ sess3.unsubscribe("sub2");
+ sess1.unsubscribe("sub3");
+ sess2.unsubscribe("sub4");
}
finally
{
- if (conn != null)
- {
- conn.close();
- }
-
if (conn1 != null)
{
conn1.close();
@@ -733,6 +701,11 @@
{
conn2.close();
}
+
+ if (conn3 != null)
+ {
+ conn3.close();
+ }
}
}
@@ -744,56 +717,56 @@
*/
protected void clusteredTopicSharedDurableLocalConsumer(boolean persistent) throws Exception
{
- Connection conn = null;
Connection conn1 = null;
Connection conn2 = null;
+ Connection conn3 = null;
try
{
//This will create 3 different connection on 3 different nodes, since
//the cf is clustered
- conn = cf.createConnection();
conn1 = cf.createConnection();
conn2 = cf.createConnection();
+ conn3 = cf.createConnection();
log.info("Created connections");
- checkConnectionsDifferentServers(conn, conn1, conn2);
- conn.setClientID("wib1");
+ checkConnectionsDifferentServers(conn1, conn2, conn3);
conn1.setClientID("wib1");
conn2.setClientID("wib1");
+ conn3.setClientID("wib1");
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
try
{
- sess.unsubscribe("sub");
+ sess1.unsubscribe("sub");
}
catch (Exception ignore) {}
try
{
- sess1.unsubscribe("sub");
+ sess2.unsubscribe("sub");
}
catch (Exception ignore) {}
try
{
- sess2.unsubscribe("sub");
+ sess3.unsubscribe("sub");
}
catch (Exception ignore) {}
- MessageConsumer cons = sess.createDurableSubscriber(topic, "sub");
MessageConsumer cons1 = sess1.createDurableSubscriber(topic1, "sub");
MessageConsumer cons2 = sess2.createDurableSubscriber(topic2, "sub");
+ MessageConsumer cons3 = sess3.createDurableSubscriber(topic3, "sub");
- conn.start();
conn1.start();
conn2.start();
+ conn3.start();
// Send at node 0
- MessageProducer prod = sess.createProducer(topic);
+ MessageProducer prod = sess1.createProducer(topic1);
prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
@@ -801,105 +774,100 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = sess.createTextMessage("message" + i);
+ TextMessage tm = sess1.createTextMessage("message" + i);
prod.send(tm);
}
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons.receive(1000);
+ TextMessage tm = (TextMessage)cons1.receive(1000);
assertNotNull(tm);
assertEquals("message" + i, tm.getText());
}
- Message m = cons1.receive(2000);
+ Message m = cons2.receive(2000);
assertNull(m);
- m = cons2.receive(2000);
+ m = cons3.receive(2000);
assertNull(m);
// Send at node 1
- MessageProducer prod1 = sess1.createProducer(topic1);
+ MessageProducer prod1 = sess2.createProducer(topic2);
prod1.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = sess2.createTextMessage("message" + i);
+ TextMessage tm = sess3.createTextMessage("message" + i);
prod1.send(tm);
}
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons1.receive(1000);
+ TextMessage tm = (TextMessage)cons2.receive(1000);
assertNotNull(tm);
assertEquals("message" + i, tm.getText());
}
- m = cons.receive(2000);
+ m = cons1.receive(2000);
assertNull(m);
- m = cons2.receive(2000);
+ m = cons3.receive(2000);
assertNull(m);
// Send at node 2
- MessageProducer prod2 = sess2.createProducer(topic2);
+ MessageProducer prod2 = sess3.createProducer(topic3);
prod2.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = sess2.createTextMessage("message" + i);
+ TextMessage tm = sess3.createTextMessage("message" + i);
prod2.send(tm);
}
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = (TextMessage)cons2.receive(1000);
+ TextMessage tm = (TextMessage)cons3.receive(1000);
assertNotNull(tm);
assertEquals("message" + i, tm.getText());
}
- m = cons.receive(2000);
+ m = cons1.receive(2000);
assertNull(m);
- m = cons1.receive(2000);
+ m = cons2.receive(2000);
assertNull(m);
- cons.close();
cons1.close();
cons2.close();
+ cons3.close();
// Need to unsubscribe on any node that the durable sub was created on
- sess.unsubscribe("sub");
sess1.unsubscribe("sub");
sess2.unsubscribe("sub");
+ sess3.unsubscribe("sub");
}
finally
{
- if (conn != null)
- {
- conn.close();
- }
-
if (conn1 != null)
{
conn1.close();
@@ -909,6 +877,11 @@
{
conn2.close();
}
+
+ if (conn3 != null)
+ {
+ conn3.close();
+ }
}
}
@@ -921,51 +894,51 @@
*/
protected void clusteredTopicSharedDurableNoLocalSub(boolean persistent) throws Exception
{
- Connection conn = null;
Connection conn1 = null;
Connection conn2 = null;
+ Connection conn3 = null;
try
{
//This will create 3 different connection on 3 different nodes, since
//the cf is clustered
- conn = cf.createConnection();
conn1 = cf.createConnection();
conn2 = cf.createConnection();
+ conn3 = cf.createConnection();
log.info("Created connections");
- checkConnectionsDifferentServers(conn, conn1, conn2);
+ checkConnectionsDifferentServers(conn1, conn2, conn3);
- conn1.setClientID("wib1");
conn2.setClientID("wib1");
+ conn3.setClientID("wib1");
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
try
{
- sess1.unsubscribe("sub");
+ sess2.unsubscribe("sub");
}
catch (Exception ignore) {}
try
{
- sess2.unsubscribe("sub");
+ sess3.unsubscribe("sub");
}
catch (Exception ignore) {}
- MessageConsumer cons1 = sess1.createDurableSubscriber(topic1, "sub");
- MessageConsumer cons2 = sess2.createDurableSubscriber(topic2, "sub");
+ MessageConsumer cons1 = sess2.createDurableSubscriber(topic2, "sub");
+ MessageConsumer cons2 = sess3.createDurableSubscriber(topic3, "sub");
- conn1.start();
conn2.start();
+ conn3.start();
// Send at node 0
//Should round robin between the other 2 since there is no active consumer on sub on node 0
- MessageProducer prod = sess.createProducer(topic);
+ MessageProducer prod = sess1.createProducer(topic1);
prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
@@ -973,7 +946,7 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- TextMessage tm = sess.createTextMessage("message" + i);
+ TextMessage tm = sess1.createTextMessage("message" + i);
prod.send(tm);
}
@@ -999,17 +972,12 @@
cons1.close();
cons2.close();
- sess1.unsubscribe("sub");
sess2.unsubscribe("sub");
+ sess3.unsubscribe("sub");
}
finally
{
- if (conn != null)
- {
- conn.close();
- }
-
if (conn1 != null)
{
conn1.close();
@@ -1019,6 +987,11 @@
{
conn2.close();
}
+
+ if (conn3 != null)
+ {
+ conn3.close();
+ }
}
}
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/SimpleClusteringTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/SimpleClusteringTest.java 2006-12-08 12:15:43 UTC (rev 1725)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/SimpleClusteringTest.java 2006-12-08 12:44:52 UTC (rev 1726)
@@ -59,15 +59,15 @@
SimpleMessageListener ml1 = new SimpleMessageListener();
SimpleMessageListener ml2 = new SimpleMessageListener();
- s.createConsumer(topic).setMessageListener(ml);
- s1.createConsumer(topic).setMessageListener(ml1);
- s2.createConsumer(topic).setMessageListener(ml2);
+ s.createConsumer(topic1).setMessageListener(ml);
+ s1.createConsumer(topic1).setMessageListener(ml1);
+ s2.createConsumer(topic1).setMessageListener(ml2);
conn.start();
conn1.start();
conn2.start();
- s.createProducer(topic).send(s.createTextMessage("boom"));
+ s.createProducer(topic1).send(s.createTextMessage("boom"));
TextMessage rm = null;
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java 2006-12-08 12:15:43 UTC (rev 1725)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java 2006-12-08 12:44:52 UTC (rev 1726)
@@ -31,6 +31,10 @@
import javax.jms.Topic;
import javax.naming.Context;
import javax.naming.InitialContext;
+
+import org.jboss.jms.client.JBossConnection;
+import org.jboss.jms.client.delegate.DelegateSupport;
+import org.jboss.jms.client.state.ConnectionState;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
@@ -48,21 +52,21 @@
// Attributes ----------------------------------------------------
- protected Context ic;
protected Context ic1;
protected Context ic2;
+ protected Context ic3;
- protected Queue queue;
protected Queue queue1;
protected Queue queue2;
+ protected Queue queue3;
- protected Topic topic;
protected Topic topic1;
protected Topic topic2;
+ protected Topic topic3;
+ //No need to have 3 conncetion factories since a clustered connection factory
+ //will create connections in a round robin fashion on different servers
protected ConnectionFactory cf;
- // protected ConnectionFactory cf1;
- // protected ConnectionFactory cf2;
// Constructors --------------------------------------------------
@@ -95,21 +99,21 @@
log.info("Deployed destinations ok");
- ic = new InitialContext(ServerManagement.getJNDIEnvironment(0));
- ic1 = new InitialContext(ServerManagement.getJNDIEnvironment(1));
- ic2 = new InitialContext(ServerManagement.getJNDIEnvironment(2));
+ ic1 = new InitialContext(ServerManagement.getJNDIEnvironment(0));
+ ic2 = new InitialContext(ServerManagement.getJNDIEnvironment(1));
+ ic3 = new InitialContext(ServerManagement.getJNDIEnvironment(2));
//We only need to lookup one connection factory since it will be a clustered cf
//so we will actually create connections on different servers (round robin)
- cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
+ cf = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
- queue = (Queue)ic.lookup("queue/testDistributedQueue");
queue1 = (Queue)ic1.lookup("queue/testDistributedQueue");
queue2 = (Queue)ic2.lookup("queue/testDistributedQueue");
+ queue3 = (Queue)ic3.lookup("queue/testDistributedQueue");
- topic = (Topic)ic.lookup("topic/testDistributedTopic");
topic1 = (Topic)ic1.lookup("topic/testDistributedTopic");
topic2 = (Topic)ic2.lookup("topic/testDistributedTopic");
+ topic3 = (Topic)ic3.lookup("topic/testDistributedTopic");
drainQueues();
}
@@ -136,9 +140,9 @@
ServerManagement.undeployQueue("testDistributedQueue", 2);
ServerManagement.undeployTopic("testDistributedTopic", 2);
- ic.close();
ic1.close();
ic2.close();
+ ic3.close();
super.tearDown();
}
@@ -148,63 +152,86 @@
throw e;
}
}
+
+ protected void checkConnectionsDifferentServers(Connection conn, Connection conn1, Connection conn2)
+ {
+ ConnectionState state = (ConnectionState)(((DelegateSupport)((JBossConnection)conn).getDelegate()).getState());
+
+ ConnectionState state1 = (ConnectionState)(((DelegateSupport)((JBossConnection)conn1).getDelegate()).getState());
+
+ ConnectionState state2 = (ConnectionState)(((DelegateSupport)((JBossConnection)conn2).getDelegate()).getState());
+
+ int serverID = state.getServerID();
+
+ int serverID1 = state1.getServerID();
+
+ int serverID2 = state2.getServerID();
+
+ log.info("Server id:" + serverID);
+
+ log.info("Server id1:" + serverID1);
+
+ log.info("Server id2:" + serverID2);
+
+
+ assertTrue(serverID != serverID1);
+
+ assertTrue(serverID1 != serverID2);
+ }
protected void drainQueues() throws Exception
{
- Connection conn = null;
Connection conn1 = null;
Connection conn2 = null;
+ Connection conn3 = null;
try
{
//Since the cf is clustered, this will create connections on 3 different nodes
//(round robin)
- conn = cf.createConnection();
conn1 = cf.createConnection();
conn2 = cf.createConnection();
+ conn3 = cf.createConnection();
+
+ checkConnectionsDifferentServers(conn1, conn2, conn3);
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sess.createConsumer(queue);
MessageConsumer cons1 = sess1.createConsumer(queue1);
MessageConsumer cons2 = sess2.createConsumer(queue2);
+ MessageConsumer cons3 = sess3.createConsumer(queue3);
- conn.start();
conn1.start();
conn2.start();
+ conn3.start();
Message msg = null;
do
{
- msg = cons.receive(1000);
+ msg = cons1.receive(1000);
log.info("1 Drained message " + msg);
}
while (msg != null);
do
{
- msg = cons1.receive(1000);
+ msg = cons2.receive(1000);
log.info("2 Drained message " + msg);
}
while (msg != null);
do
{
- msg = cons2.receive(1000);
+ msg = cons3.receive(1000);
log.info("3 Drained message " + msg);
}
while (msg != null);
}
finally
{
- if (conn != null)
- {
- conn.close();
- }
-
if (conn1 != null)
{
conn1.close();
@@ -214,6 +241,11 @@
{
conn2.close();
}
+
+ if (conn3 != null)
+ {
+ conn3.close();
+ }
}
}
More information about the jboss-cvs-commits
mailing list