qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arnaudsi...@apache.org
Subject svn commit: r602127 - in /incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct: Consumer.java Listener.java
Date Fri, 07 Dec 2007 15:37:09 GMT
Author: arnaudsimon
Date: Fri Dec  7 07:37:09 2007
New Revision: 602127

URL: http://svn.apache.org/viewvc?rev=602127&view=rev
Log:
changed for accepting messages from python and c++

Modified:
    incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Consumer.java
    incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Listener.java

Modified: incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Consumer.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Consumer.java?rev=602127&r1=602126&r2=602127&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Consumer.java
(original)
+++ incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Consumer.java
Fri Dec  7 07:37:09 2007
@@ -18,7 +18,7 @@
  * under the License.
  *
  */
-package  org.apache.qpid.example.jmsexample.direct;
+package org.apache.qpid.example.jmsexample.direct;
 
 import org.apache.qpid.example.jmsexample.common.BaseExample;
 
@@ -110,18 +110,25 @@
             while (!end)
             {
                 message = messageConsumer.receive();
+                String text = "";
                 if (message instanceof TextMessage)
                 {
-                    System.out.println(CLASS + ": Received  message:  " + ((TextMessage)
message).getText());
-                    if (((TextMessage) message).getText().equals("That's all, folks!"))
-                    {
-                        System.out.println(CLASS + ": Received final message for " + _queueName);
-                        end = true;
-                    }
+                    text = ((TextMessage) message).getText();
                 }
                 else
                 {
-                    System.out.println(CLASS + ": Received messages is  not a text message");
+                    byte[] body = new byte[(int) ((BytesMessage) message).getBodyLength()];

+                    ((BytesMessage) message).readBytes(body);
+                    text = new String(body);
+                }
+                if (text.equals("That's all, folks!"))
+                {
+                    System.out.println(CLASS + ": Received final message for " + _queueName);
+                    end = true;
+                }
+                else
+                {
+                    System.out.println(CLASS + ": Received  message:  " + text);
                 }
             }
 

Modified: incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Listener.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Listener.java?rev=602127&r1=602126&r2=602127&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Listener.java
(original)
+++ incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Listener.java
Fri Dec  7 07:37:09 2007
@@ -109,7 +109,7 @@
             Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
             // lookup the queue
-            Queue destination =  session.createQueue(_queueName);
+            Queue destination = session.createQueue(_queueName);
 
             // Create a MessageConsumer
             System.out.println(CLASS + ": Creating a MessageConsumer");
@@ -164,22 +164,29 @@
     {
         try
         {
+            String text = "";
             if (message instanceof TextMessage)
             {
-                System.out.println(CLASS + ": Received message: " + ((TextMessage) message).getText());
-                if (((TextMessage) message).getText().equals("That's all, folks!"))
+                text = ((TextMessage) message).getText();
+            }
+            else
+            {
+                byte[] body = new byte[(int) ((BytesMessage) message).getBodyLength()];
+                ((BytesMessage) message).readBytes(body);
+                text = new String(body);
+            }
+            if (text.equals("That's all, folks!"))
+            {
+                System.out.println(CLASS + ": Received final message for " + _queueName);
+                synchronized (_lock)
                 {
-                    System.out.println(CLASS + ": Shutting down listener for " + _queueName);
-                    synchronized (_lock)
-                    {
-                        _finished = true;
-                        _lock.notifyAll();
-                    }
+                    _finished = true;
+                    _lock.notifyAll();
                 }
             }
             else
             {
-                System.out.println(" [not text message]");
+                System.out.println(CLASS + ": Received  message:  " + text);
             }
         }
         catch (JMSException exp)



Mime
View raw message