[jboss-cvs] JBoss Messaging SVN: r2503 - in trunk/docs/examples/distributed-queue: src/org/jboss/example/jms/distributedqueue and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 28 17:59:47 EST 2007


Author: ovidiu.feodorov at jboss.com
Date: 2007-02-28 17:59:46 -0500 (Wed, 28 Feb 2007)
New Revision: 2503

Modified:
   trunk/docs/examples/distributed-queue/README.html
   trunk/docs/examples/distributed-queue/src/org/jboss/example/jms/distributedqueue/DistributedQueueExample.java
Log:
adjusted DistributedQueueExample to work with NullMessagePullPolicy. http://jira.jboss.org/jira/browse/JBMESSAGING-906

Modified: trunk/docs/examples/distributed-queue/README.html
===================================================================
--- trunk/docs/examples/distributed-queue/README.html	2007-02-28 21:46:25 UTC (rev 2502)
+++ trunk/docs/examples/distributed-queue/README.html	2007-02-28 22:59:46 UTC (rev 2503)
@@ -3,22 +3,28 @@
 <head>
   <meta content="text/html; charset=ISO-8859-1"
  http-equiv="content-type">
-  <title>JBoss Messaging Example - JMS Topic</title>
+  <title>JBoss Messaging Example - Distributed Queue</title>
 </head>
 <body>
 <br>
-<h1>JBoss Messaging Distributed Topic Example</h1>
+<h1>JBoss Messaging Distributed Queue Example</h1>
 $Revision: 1017 $
 <h2>Overview</h2>
 <br>
 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
-cluster nodes. Each connection is then used to create a subscriber for
-the distributed topic. The example is considered
-successful
-if both subscribers receive a message sent to the topic.<br>
+JBoss Messaging cluster and sends messages to a distributed queue.
+The example creates two connections to two distinct cluster nodes
+on which we have previously deployed a distributed queue.
+The example sends and receives messages using both connections.
 <br>
+NOTE: This is an example that assumes a NullMessagePullPolicy.
+This is the default configuration option a release ships with,
+and also is a very boring options, since messages are *NOT*
+redistributed among nodes.
+<br>
+An example that assumes a DefaultMessagePullPolicy is coming
+soon (http://jira.jboss.org/jira/browse/JBMESSAGING-907).
+<br>
 This example relies on having access to a running JBoss Messaging
 cluster with at least two nodes. The JBoss Messaging cluster must be
 installed and started according to
@@ -49,7 +55,7 @@
 2. Go to the example's home directory<br>
 <br>
 <div style="margin-left: 40px;"><span style="font-family: monospace;">cd
-...\examples\distributed-topic</span><br>
+...\examples\distributed-queue</span><br>
 </div>
 <br>
 3. Run the example:<br>
@@ -78,13 +84,13 @@
 ###########################################################################<br>
 &nbsp;&nbsp;&nbsp;&nbsp; [echo]
 #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-Running the DISTRIBUTED TOPIC
+Running the DISTRIBUTED QUEUE
 example&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 #<br>
 &nbsp;&nbsp;&nbsp;&nbsp; [echo]
 ###########################################################################<br>
 &nbsp;&nbsp;&nbsp;&nbsp; [echo] The
-topic:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; testDistributedTopic<br>
+topic:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; testDistributedQueue<br>
 &nbsp;&nbsp;&nbsp;&nbsp; [echo] The client jar:
 ../../../output/lib/jboss-messaging-client.jar<br>
       <br>
@@ -92,7 +98,7 @@
       <br>
 init:<br>
 &nbsp;&nbsp;&nbsp; [mkdir] Created dir:
-C:\work\src\svn\messaging\docs\examples\distributed-topic\output<br>
+C:\work\src\svn\messaging\docs\examples\distributed-queue\output<br>
 &nbsp;&nbsp;&nbsp; [mkdir] Created dir:
 C:\work\src\svn\messaging\docs\examples\common\output<br>
       <br>
@@ -100,19 +106,19 @@
 &nbsp;&nbsp;&nbsp; [javac] Compiling 2 source files to
 C:\work\src\svn\messaging\docs\examples\common\output<br>
 &nbsp;&nbsp;&nbsp; [javac] Compiling 2 source files to
-C:\work\src\svn\messaging\docs\examples\distributed-topic\output<br>
+C:\work\src\svn\messaging\docs\examples\distributed-queue\output<br>
       <br>
 run:<br>
-&nbsp;&nbsp;&nbsp;&nbsp; [java] Distributed topic
-/topic/testDistributedTopic exists<br>
-&nbsp;&nbsp;&nbsp;&nbsp; [java] The message was successfully published
-on the distributed topic<br>
-&nbsp;&nbsp;&nbsp;&nbsp; [java] MessageListener 1 received message:
+&nbsp;&nbsp;&nbsp;&nbsp; [java] Distributed queue
+/queue/testDistributedQueue exists<br>
+&nbsp;&nbsp;&nbsp;&nbsp; [java] The message was successfully sent
+to the distributed queue<br>
+&nbsp;&nbsp;&nbsp;&nbsp; [java] MessageListener0 received message:
 Hello!<br>
-&nbsp;&nbsp;&nbsp;&nbsp; [java] MessageListener 2 received message:
-Hello!<br>
+&nbsp;&nbsp;&nbsp;&nbsp; [java] MessageListener1 received message:
+Another Hello!<br>
 &nbsp;&nbsp;&nbsp;&nbsp; [java] The example connected to JBoss
-Messaging version 1.2.0.Beta1 (1.2)<br>
+Messaging version 1.2.0.GA (1.2)<br>
       <br>
 &nbsp;&nbsp;&nbsp;&nbsp; [java] #####################<br>
 &nbsp;&nbsp;&nbsp;&nbsp; [java] ###&nbsp;&nbsp;&nbsp;

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-28 21:46:25 UTC (rev 2502)
+++ trunk/docs/examples/distributed-queue/src/org/jboss/example/jms/distributedqueue/DistributedQueueExample.java	2007-02-28 22:59:46 UTC (rev 2503)
@@ -35,12 +35,13 @@
 
 /**
  * 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. The JBoss Messaging clustered Post Offices
- * need to be configured with a default message redistribution policy for this example to work
- * correctly.
+ * deployed a distributed queue. The example sends and receives messages using both connections.
  *
+ * NOTE: This is an example that assumes a NullMessagePullPolicy. This is the default configuration
+ *       option a release ships with, and also is a very boring options, since messages are *NOT*
+ *       redistributed among nodes. An example that assumes a DefaultMessagePullPolicy is coming
+ *       soon (http://jira.jboss.org/jira/browse/JBMESSAGING-907).
+ *
  * 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.
  *
@@ -84,39 +85,52 @@
          // 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
+         // Create a session, a producer and a consumer on the first connection
 
          Session session0 = connection0.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer publisher = session0.createProducer(distributedQueue);
+         MessageProducer publisher0 = session0.createProducer(distributedQueue);
+         MessageConsumer consumer0 = session0.createConsumer(distributedQueue);
+         ExampleListener messageListener0 = new ExampleListener("MessageListener0");
+         consumer0.setMessageListener(messageListener0);
 
+         // Create another session, producer and consumer on the second connection
 
-         // 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);
+         MessageProducer publisher1 = session1.createProducer(distributedQueue);
+         MessageConsumer consumer1 = session1.createConsumer(distributedQueue);
+         ExampleListener messageListener1 = new ExampleListener("MessageListener1");
+         consumer1.setMessageListener(messageListener1);
 
-         // Start connection1, so we can receive the message
+         // Start connections, so we can receive the message
 
+         connection0.start();
          connection1.start();
 
-         // Sendi the message
+         // Send the message
 
          TextMessage message = session0.createTextMessage("Hello!");
-         publisher.send(message);
+         publisher0.send(message);
 
-         log("The message was successfully sent to the distributed queue");
+         message = session1.createTextMessage("Another Hello!");
+         publisher1.send(message);
 
+         log("The messages were successfully sent to the distributed queue");
 
-         // Wait longer than clustered Post Office's "StatsSendPeriod", which is usually 10 secs
-         messageListener.waitForMessage(15000);
+         // NOTE: We know that this example is extremely boring, but so it's NullMessagePullPolicy.
+         //       However, this is the default configuration option a release ships with.
 
+         messageListener0.waitForMessage(3000);
 
-         message = (TextMessage)messageListener.getMessage();
-         log(messageListener.getName() + " received message: " + message.getText());
+         message = (TextMessage)messageListener0.getMessage();
+         log(messageListener0.getName() + " received message: " + message.getText());
          assertEquals("Hello!", message.getText());
 
+         messageListener1.waitForMessage(3000);
+
+         message = (TextMessage)messageListener1.getMessage();
+         log(messageListener1.getName() + " received message: " + message.getText());
+         assertEquals("Another Hello!", message.getText());
+
          displayProviderInfo(connection0.getMetaData());
 
       }




More information about the jboss-cvs-commits mailing list