qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arnaudsi...@apache.org
Subject svn commit: r600561 - in /incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/requestResponse: MessageMirror.java P2PRequestor.java PubSubRequestor.java
Date Mon, 03 Dec 2007 15:06:51 GMT
Author: arnaudsimon
Date: Mon Dec  3 07:06:51 2007
New Revision: 600561

URL: http://svn.apache.org/viewvc?rev=600561&view=rev
Log:
Updated ofr converting request text in upercase text

Modified:
    incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/requestResponse/MessageMirror.java
    incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/requestResponse/P2PRequestor.java
    incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/requestResponse/PubSubRequestor.java

Modified: incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/requestResponse/MessageMirror.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/requestResponse/MessageMirror.java?rev=600561&r1=600560&r2=600561&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/requestResponse/MessageMirror.java
(original)
+++ incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/requestResponse/MessageMirror.java
Mon Dec  3 07:06:51 2007
@@ -142,8 +142,6 @@
 
                 // Print out the details of the just received message
                 System.out.println(CLASS + ": Message received:");
-                System.out.println("\tID=" + requestMessage.getJMSMessageID());
-                System.out.println("\tCorrelationID=" + requestMessage.getJMSCorrelationID());
 
                 if (requestMessage instanceof TextMessage)
                 {
@@ -160,11 +158,11 @@
                 {
                     System.out.println("Activating response queue listener for: " + destination);
                     responseMessage =
-                            session.createTextMessage("Activating response queue listener
for: " + destination);
-                    String correlationID = requestMessage.getJMSCorrelationID();
-                    if (correlationID != null)
+                            session.createTextMessage();
+                     if (requestMessage instanceof TextMessage)
                     {
-                        responseMessage.setJMSCorrelationID(correlationID);
+                       responseMessage.setText(((TextMessage) requestMessage).getText().toUpperCase());
+                        System.out.println("\tResponse = " + responseMessage.getText());
                       
                     }
                     messageProducer = session.createProducer(requestMessage.getJMSReplyTo());
                     messageProducer.send(responseMessage);

Modified: incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/requestResponse/P2PRequestor.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/requestResponse/P2PRequestor.java?rev=600561&r1=600560&r2=600561&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/requestResponse/P2PRequestor.java
(original)
+++ incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/requestResponse/P2PRequestor.java
Mon Dec  3 07:06:51 2007
@@ -107,42 +107,19 @@
             // Create a message to send as a request for service
             TextMessage request;
 
-            request = session.createTextMessage("\"Twas brillig, and the slithy toves\",\n"
+
-                    "\t\t\"Did gire and gymble in the wabe.\",\n" +
-                    "\t\t\"All mimsy were the borogroves,\",\n" +
-                    "\t\t\"And the mome raths outgrabe.\"");
+            request = session.createTextMessage();
 
-            // Declare a message to be used for receiving any response
-           Message response;
-
-            // Get the number of times that this sample should request service
+         // Get the number of times that this sample should request service
             for (int i = 0; i < getNumberMessages(); i++)
             {
-                /**
-                 * Set a message correlation value. This is not strictly required it is
-                 * just an example of how messages requests can be tied together.
-                 */
-                request.setJMSCorrelationID("Message " + i);
-                System.out.println(CLASS + ": Sending request " + i);
-
-                response = requestor.request(request);
-
-                // Print out the details of the message sent
-                System.out.println(CLASS + ": Message details of request");
-                System.out.println("\tID = " + request.getJMSMessageID());
-                System.out.println("\tCorrelationID = " + request.getJMSCorrelationID());
-                 System.out.println("\tContents= " + ((TextMessage)request).getText());
-
-                // Print out the details of the response received
-                System.out.println(CLASS + ": Message details of response");
-                System.out.println("\tID = " + response.getJMSMessageID());
-                System.out.println("\tCorrelationID = " + response.getJMSCorrelationID());
-                if (response instanceof TextMessage)
-                {
-                    System.out.println("\tContents= " + ((TextMessage) response).getText());
-                }
-
-                System.out.println();
+                request = session.createTextMessage("Twas brillig, and the slithy toves");
+                sendReceive(request, requestor);
+                request = session.createTextMessage("Did gire and gymble in the wabe");
+                sendReceive(request, requestor);
+                request = session.createTextMessage("All mimsy were the borogroves,");
+                sendReceive(request, requestor);
+                request = session.createTextMessage("And the mome raths outgrabe.");
+                sendReceive(request, requestor);
             }
 
             //send the final message  for ending the mirror
@@ -162,6 +139,18 @@
         catch (Exception exp)
         {
             System.err.println(CLASS + ": Caught an Exception: " + exp);
+        }
+    }
+
+     private void sendReceive(TextMessage request, QueueRequestor requestor) throws JMSException
+    {
+        Message response;
+        response = requestor.request(request);
+        System.out.println("\tRequest Contents= " + request.getText());
+        // Print out the details of the response received
+        if (response instanceof TextMessage)
+        {
+            System.out.println("\t Response Contents= " + ((TextMessage) response).getText());
         }
     }
 }

Modified: incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/requestResponse/PubSubRequestor.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/requestResponse/PubSubRequestor.java?rev=600561&r1=600560&r2=600561&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/requestResponse/PubSubRequestor.java
(original)
+++ incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/requestResponse/PubSubRequestor.java
Mon Dec  3 07:06:51 2007
@@ -105,38 +105,19 @@
 
             // Create a message to send as a request for service
             TextMessage request;
-            request = session.createTextMessage(
-                    "\"Twas brillig, and the slithy toves\",\n" + "\t\t\"Did gire and gymble
in the wabe.\",\n" + "\t\t\"All mimsy were the borogroves,\",\n" + "\t\t\"And the mome raths
outgrabe.\"");
-
-            // Declare a message to be used for receiving any response
-            Message response;
+            request = session.createTextMessage();                   
 
             // Get the number of times that this sample should request service
             for (int i = 0; i < getNumberMessages(); i++)
             {
-                /**
-                 * Set a message correlation value. This is not strictly required it is
-                 * just an example of how messages requests can be tied together.
-                 */
-                request.setJMSCorrelationID("Message " + i);
-                System.out.println(CLASS + ": Sending request " + i);
-
-                response = requestor.request(request);
-
-                // Print out the details of the message sent
-                System.out.println(CLASS + ": Message details of request");
-                System.out.println("\tID = " + request.getJMSMessageID());
-                System.out.println("\tCorrelationID = " + request.getJMSCorrelationID());
-                System.out.println("\tContents= " + ((TextMessage) request).getText());
-
-                // Print out the details of the response received
-                System.out.println(CLASS + ": Message details of response");
-                System.out.println("\tID = " + response.getJMSMessageID());
-                System.out.println("\tCorrelationID = " + response.getJMSCorrelationID());
-                if (response instanceof TextMessage)
-                {
-                    System.out.println("\tContents= " + ((TextMessage) response).getText());
-                }
+                request = session.createTextMessage("Twas brillig, and the slithy toves");
+                sendReceive(request, requestor);
+                request = session.createTextMessage("Did gire and gymble in the wabe");
+                sendReceive(request, requestor);
+                request = session.createTextMessage("All mimsy were the borogroves,");
+                sendReceive(request, requestor);
+                request = session.createTextMessage("And the mome raths outgrabe.");
+                sendReceive(request, requestor);
             }
             // And send a final message to indicate termination.
             request.setText("That's all, folks!");
@@ -154,6 +135,18 @@
         catch (Exception exp)
         {
             System.err.println(CLASS + ": Caught an Exception: " + exp);
+        }
+    }
+
+    private void sendReceive(TextMessage request, TopicRequestor requestor) throws JMSException
+    {
+        Message response;
+        response = requestor.request(request);
+        System.out.println("\tRequest Contents= " + request.getText());
+        // Print out the details of the response received
+        if (response instanceof TextMessage)
+        {
+            System.out.println("\t Response Contents= " + ((TextMessage) response).getText());
         }
     }
 }



Mime
View raw message