[jboss-cvs] JBoss Messaging SVN: r5338 - in branches/Branch_1416_merge: docs/examples/ordering-group/src/org/jboss/example/jms/ordering and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Nov 11 07:27:29 EST 2008


Author: gaohoward
Date: 2008-11-11 07:27:28 -0500 (Tue, 11 Nov 2008)
New Revision: 5338

Modified:
   branches/Branch_1416_merge/docs/examples/ordering-group/README.html
   branches/Branch_1416_merge/docs/examples/ordering-group/src/org/jboss/example/jms/ordering/ConsumerThread.java
   branches/Branch_1416_merge/docs/examples/ordering-group/src/org/jboss/example/jms/ordering/OrderingGroupExample.java
   branches/Branch_1416_merge/integration/EAP4/.classpath
Log:
JBMESSAGING-1416 code clean-up


Modified: branches/Branch_1416_merge/docs/examples/ordering-group/README.html
===================================================================
--- branches/Branch_1416_merge/docs/examples/ordering-group/README.html	2008-11-11 11:43:36 UTC (rev 5337)
+++ branches/Branch_1416_merge/docs/examples/ordering-group/README.html	2008-11-11 12:27:28 UTC (rev 5338)
@@ -3,22 +3,28 @@
 <head>
   <meta content="text/html; charset=ISO-8859-1"
  http-equiv="content-type">
-  <title>JBoss Messaging Example - JMS Queue</title>
+  <title>JBoss Messaging Example - Ordering Group</title>
 </head>
 <body>
 <br>
-<h1>JBoss Messaging Queue Example</h1>
+<h1>JBoss Messaging Ordering Group Example</h1>
+
 $Revision: 2750 $
+
 <h2>Overview</h2>
+
 <br>
-This example creates a JMS Connection to a JBoss Messaging instance
-and uses it to create a session and a message producer, which sends a
-message to the queue "queue/testQueue".&nbsp; Then, the example uses
-the same connection to create a consumer that that reads
-a single message from the queue. The example is considered successful
-if the message consumer receives without any error the message that was
-sent by the producer. <br>
+
+This example creates a JMS Connection to a JBoss Messaging instance and uses it to create a
+session and two message producers, one normal producer called 'producer1', the other producer
+called 'producer' is used to produce ordering group messages. Then both producers send 5 messages
+(producer1 sending 2 and producer 3) to "queue/testQueue". The example then starts two consumer 
+threads to receive these messages. Once the messages are all received, it check the results.<br>
 <br>
+This example illustrates that ordering group messages will be delivered exactly in the same
+order as they are sent, even if the messages has different priorities and are consumed by
+multiple consumers at the same time.
+<br>
 This example relies on having access to a running JBoss Messaging
 instance.
 The JBoss Messaging instance must be installed and started according to
@@ -72,7 +78,7 @@
 
 identify:
      [echo] ###########################################################################
-     [echo] #                       Running the QUEUE example                         #
+     [echo] #                       Running the ORDERING-GROUP example                         #
      [echo] ###########################################################################
      [echo] The queue:      testQueue
      [echo] The client jar: ../../../output/lib/jboss-messaging-client.jar

Modified: branches/Branch_1416_merge/docs/examples/ordering-group/src/org/jboss/example/jms/ordering/ConsumerThread.java
===================================================================
--- branches/Branch_1416_merge/docs/examples/ordering-group/src/org/jboss/example/jms/ordering/ConsumerThread.java	2008-11-11 11:43:36 UTC (rev 5337)
+++ branches/Branch_1416_merge/docs/examples/ordering-group/src/org/jboss/example/jms/ordering/ConsumerThread.java	2008-11-11 12:27:28 UTC (rev 5338)
@@ -21,17 +21,19 @@
  */
 package org.jboss.example.jms.ordering;
 
-import java.util.Random;
-
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.JMSException;
 import javax.jms.MessageConsumer;
 import javax.jms.Session;
 import javax.jms.TextMessage;
-import javax.jms.Topic;
 import javax.jms.Destination;
 
+/**
+ *
+ * @author <a href="mailto:hgao at redhat.com">Howard Gao</a>
+ *
+ */
 public class ConsumerThread extends Thread
 {
    private OrderingGroupExample example;
@@ -67,23 +69,17 @@
       int n = example.getNumMessages();
       try
       {
-         System.err.println(getName() + " start working now.....");
-         int timeToSleep = 0;
          while (true)
          {
             if (example.allReceived())
             {
-               System.err.println("message all received, break.");
                break;
             }
             TextMessage msg = (TextMessage)consumer.receive(2000);
             if (msg != null)
             {
-               System.err.println("Message received: " + msg.getText() + " by " + this.getName());
-               //System.err.println("No Calling ack");
                if (msg.getText().equals(OrderingGroupExample.ORDERING_MSG1))
                {
-                  System.err.println("First message got by me (" + getName() + "), so sleep");
                   //whoever receives first message, delay for 2 sec.
                   delay(2000);
                }

Modified: branches/Branch_1416_merge/docs/examples/ordering-group/src/org/jboss/example/jms/ordering/OrderingGroupExample.java
===================================================================
--- branches/Branch_1416_merge/docs/examples/ordering-group/src/org/jboss/example/jms/ordering/OrderingGroupExample.java	2008-11-11 11:43:36 UTC (rev 5337)
+++ branches/Branch_1416_merge/docs/examples/ordering-group/src/org/jboss/example/jms/ordering/OrderingGroupExample.java	2008-11-11 12:27:28 UTC (rev 5338)
@@ -26,8 +26,6 @@
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
 import javax.jms.Queue;
 import javax.jms.Session;
 import javax.jms.TextMessage;
@@ -39,20 +37,17 @@
 
 /**
  * This example creates a JMS Connection to a JBoss Messaging instance and uses it to create a
- * session and a message producer, which sends a message to the queue "queue/testQueue".  Then, the
- * example uses the same connection to create a consumer that that reads a single message from the
- * queue. The example is considered successful if the message consumer receives without any error
- * the message that was sent by the producer.
+ * session and two message producers, one normal producer called 'producer1', the other producer
+ * called 'producer' is used to produce ordering group messages. Then both producers send 5 messages
+ * (producer1 sending 2 and producer 3) to "queue/testQueue". The example then starts two consumer 
+ * threads to receive these messages. Once the messages are all received, it check the results.
  * 
- * Since this example is also used by the 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.
+ * This example illustrates that ordering group messages will be delivered exactly in the same
+ * order as they are sent, even if the messages has different priorities and are consumed by
+ * multiple consumers at the same time.
  *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:luc.texier at jboss.org">Luc Texier</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 2868 $</tt>
+ * @author <a href="mailto:hgao at redhat.com">Howard Gao</a>
  *
- * $Id: QueueExample.java 2868 2007-07-10 20:22:16Z timfox $
  */
 public class OrderingGroupExample extends ExampleSupport
 {
@@ -68,22 +63,18 @@
    {
       int len = deliveryRecords.size();
       System.out.println("len: " + len);
-      if (len != 5)
-      {
-         System.err.println("=====Error, the len is not 5!=====");
-      }
+      assertEquals(5, len);
+
       int n1 = deliveryRecords.indexOf(ORDERING_MSG1);
       int n2 = deliveryRecords.indexOf(ORDERING_MSG2);
       int n3 = deliveryRecords.indexOf(ORDERING_MSG3);
-      System.out.println("n1: " + n1 + " n2: " + n2 + " n3: " + n3);
+
+      int flag = 1;
       if ( (n1 < n2) && (n2 < n3) )
       {
-         System.out.println("=====Correct=======");
+         flag = 0;
       }
-      else
-      {
-         System.err.println("=====Error======");
-      }
+      assertEquals(0, flag);
    }
 
    public boolean allReceived()

Modified: branches/Branch_1416_merge/integration/EAP4/.classpath
===================================================================
--- branches/Branch_1416_merge/integration/EAP4/.classpath	2008-11-11 11:43:36 UTC (rev 5337)
+++ branches/Branch_1416_merge/integration/EAP4/.classpath	2008-11-11 12:27:28 UTC (rev 5338)
@@ -15,6 +15,7 @@
 	<classpathentry kind="src" path="docs/examples/ejb3mdb/src"/>
 	<classpathentry kind="src" path="docs/examples/http/src"/>
 	<classpathentry kind="src" path="docs/examples/mdb/src"/>
+	<classpathentry kind="src" path="docs/examples/ordering-group/src"/>
 	<classpathentry kind="src" path="docs/examples/queue/src"/>
 	<classpathentry kind="src" path="docs/examples/secure-socket/src"/>
 	<classpathentry kind="src" path="docs/examples/stateless/src"/>




More information about the jboss-cvs-commits mailing list