[jboss-cvs] JBoss Messaging SVN: r2306 - trunk/docs/examples/distributed-queue/src/org/jboss/example/jms/distributedqueue.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Feb 13 20:04:16 EST 2007


Author: ovidiu.feodorov at jboss.com
Date: 2007-02-13 20:04:15 -0500 (Tue, 13 Feb 2007)
New Revision: 2306

Modified:
   trunk/docs/examples/distributed-queue/src/org/jboss/example/jms/distributedqueue/DistributedQueueExample.java
Log:
working distributed queue example; http://jira.jboss.org/jira/browse/JBMESSAGING-690 partially completed

Modified: trunk/docs/examples/distributed-queue/src/org/jboss/example/jms/distributedqueue/DistributedQueueExample.java
===================================================================
--- trunk/docs/examples/distributed-queue/src/org/jboss/example/jms/distributedqueue/DistributedQueueExample.java	2007-02-14 01:02:40 UTC (rev 2305)
+++ trunk/docs/examples/distributed-queue/src/org/jboss/example/jms/distributedqueue/DistributedQueueExample.java	2007-02-14 01:04:15 UTC (rev 2306)
@@ -37,7 +37,9 @@
  * The example creates two connections to two distinct cluster nodes on which we have previously
  * deployed a distributed queue. The example creates and sends a message using a connection, and
  * attempts to receive the message using the other connection. This is an example of message
- * redistribution in clustered environment at work.
+ * redistribution in clustered environment at work. The JBoss Messaging clustered Post Offices
+ * need to be configured with a default message redistribution policy for this example to work
+ * correctly.
  *
  * Since this example is also used as a smoke test, it is essential that the VM exits with exit
  * code 0 in case of successful execution and a non-zero value on failure.
@@ -76,29 +78,29 @@
          // ... so this is a connection to a cluster node
          connection0 = cf.createConnection();
 
-//         // ... and this is a connection to a different cluster node
-//         connection1 = cf.createConnection();
-//
-//         // Let's make sure that (this example is also a smoke test)
-//         assertNotEquals(getServerID(connection0), getServerID(connection1));
+         // ... and this is a connection to a different cluster node
+         connection1 = cf.createConnection();
 
+         // Let's make sure that (this example is also a smoke test)
+         assertNotEquals(getServerID(connection0), getServerID(connection1));
+
          // Create a session and a producer on the first connection
 
          Session session0 = connection0.createSession(false, Session.AUTO_ACKNOWLEDGE);
          MessageProducer publisher = session0.createProducer(distributedQueue);
 
 
-//         // Create another session and a consumer on the second connection
-//
-//         Session session1 = connection1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-//         MessageConsumer consumer = session1.createConsumer(distributedQueue);
-//         ExampleListener messageListener = new ExampleListener("MessageListener");
-//         consumer.setMessageListener(messageListener);
-//
-//         // Start connection1, so we can receive the message
-//
-//         connection1.start();
+         // Create another session and a consumer on the second connection
 
+         Session session1 = connection1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         MessageConsumer consumer = session1.createConsumer(distributedQueue);
+         ExampleListener messageListener = new ExampleListener("MessageListener");
+         consumer.setMessageListener(messageListener);
+
+         // Start connection1, so we can receive the message
+
+         connection1.start();
+
          // Sendi the message
 
          TextMessage message = session0.createTextMessage("Hello!");
@@ -107,13 +109,13 @@
          log("The message was successfully sent to the distributed queue");
 
 
-//         messageListener.waitForMessage();
-//
-//
-//         message = (TextMessage)messageListener.getMessage();
-//         log(messageListener.getName() + " received message: " + message.getText());
-//         assertEquals("Hello!", message.getText());
+         messageListener.waitForMessage();
 
+
+         message = (TextMessage)messageListener.getMessage();
+         log(messageListener.getName() + " received message: " + message.getText());
+         assertEquals("Hello!", message.getText());
+
          displayProviderInfo(connection0.getMetaData());
 
       }




More information about the jboss-cvs-commits mailing list