[jboss-cvs] JBoss Messaging SVN: r1836 - in trunk/docs/examples/queue-failover: . src/org/jboss/example/jms/failover
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Dec 20 06:14:35 EST 2006
Author: timfox
Date: 2006-12-20 06:14:32 -0500 (Wed, 20 Dec 2006)
New Revision: 1836
Modified:
trunk/docs/examples/queue-failover/README.html
trunk/docs/examples/queue-failover/src/org/jboss/example/jms/failover/QueueFailoverExample.java
Log:
Improved test
Modified: trunk/docs/examples/queue-failover/README.html
===================================================================
--- trunk/docs/examples/queue-failover/README.html 2006-12-20 11:01:42 UTC (rev 1835)
+++ trunk/docs/examples/queue-failover/README.html 2006-12-20 11:14:32 UTC (rev 1836)
@@ -7,10 +7,13 @@
</head>
<body>
<br>
-<h1>JBoss Messaging Distributed Topic Example</h1>
+<h1>JBoss Messaging Queue Consumer Failover Example</h1>
$Revision: 1017 $
<h2>Overview</h2>
<br>
+
+This example
+
This example demonstrates how to write JMS code that connects to a
JBoss Messaging cluster and sends messages to a distributed topic. The
client code creates two distinct JMS connections to two different
Modified: trunk/docs/examples/queue-failover/src/org/jboss/example/jms/failover/QueueFailoverExample.java
===================================================================
--- trunk/docs/examples/queue-failover/src/org/jboss/example/jms/failover/QueueFailoverExample.java 2006-12-20 11:01:42 UTC (rev 1835)
+++ trunk/docs/examples/queue-failover/src/org/jboss/example/jms/failover/QueueFailoverExample.java 2006-12-20 11:14:32 UTC (rev 1836)
@@ -79,19 +79,31 @@
connection.start();
- // Send a message to the queue
+ // Send 2 messagea to the queue
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
MessageProducer producer = session.createProducer(distributedQueue);
- TextMessage message = session.createTextMessage("Hello!");
- producer.send(message);
+ TextMessage message1 = session.createTextMessage("Hello1!");
+ producer.send(message1);
+
+ TextMessage message2 = session.createTextMessage("Hello2!");
+
+ producer.send(message2);
+
+ log("The messages were successfully sent to the distributed queue");
+
+ // Now receive one of the messages
+
MessageConsumer consumer = session.createConsumer(distributedQueue);
+ TextMessage rm1 = (TextMessage)consumer.receive(2000);
- log("The message was successfully sent to the distributed queue");
+ log("Received message: " + rm1.getText());
+ assertEquals("Hello1!", rm1.getText());
// Kill the active node
@@ -101,12 +113,14 @@
Thread.sleep(30000); // TODO not necesare after we install the client valve
- // receive the message
+ // receive the second message on the failed over node
- message = (TextMessage)consumer.receive(2000);
- log("Received message: " + message.getText());
- assertEquals("Hello!", message.getText());
+ TextMessage rm2 = (TextMessage)consumer.receive(2000);
+ log("Received message: " + rm2.getText());
+
+ assertEquals("Hello2!", rm2.getText());
+
displayProviderInfo(connection.getMetaData());
}
More information about the jboss-cvs-commits
mailing list