qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ai...@apache.org
Subject svn commit: r674747 - in /incubator/qpid/trunk/qpid/java/client/src: main/java/org/apache/qpid/client/BasicMessageConsumer.java test/java/org/apache/qpid/client/MessageListenerTest.java
Date Tue, 08 Jul 2008 09:07:38 GMT
Author: aidan
Date: Tue Jul  8 02:07:37 2008
New Revision: 674747

URL: http://svn.apache.org/viewvc?rev=674747&view=rev
Log:
QPID-293 allow messages which have been received by the consumer before a message listener
has been set to be delivered.

BasicMessageConsumer.java: If there are messages on the synchronous queue when a message listener
is set, deliver them to it since they can no longer be consumed().

MessageListenerTest.java: Uncomment code that will make the test fail and demonstrate the
bug

Modified:
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java
    incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/MessageListenerTest.java

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java?rev=674747&r1=674746&r2=674747&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java
(original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java
Tue Jul  8 02:07:37 2008
@@ -277,6 +277,14 @@
                     _messageListener.set(messageListener);
                     _session.setHasMessageListeners();
                     _session.startDispatcherIfNecessary();
+                    
+                    // If we already have messages on the queue, deliver them to the listener
+                    Object o = _synchronousQueue.poll();
+                    while (o != null)
+                    {
+                        messageListener.onMessage((Message) o);
+                        o = _synchronousQueue.poll();
+                    }
                 }
             }
         }

Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/MessageListenerTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/MessageListenerTest.java?rev=674747&r1=674746&r2=674747&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/MessageListenerTest.java
(original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/MessageListenerTest.java
Tue Jul  8 02:07:37 2008
@@ -132,16 +132,16 @@
 
     }
 
-    public void testRecieveTheUseMessageListener() throws Exception
+    public void testRecieveThenUseMessageListener() throws Exception
     {
 
         _logger.error("Test disabled as initial receive is not called first");
         // Perform initial receive to start connection
-        // assertTrue(_consumer.receive(2000) != null);
-        // receivedCount++;
+        assertTrue(_consumer.receive(2000) != null);
+        receivedCount++;
 
         // Sleep to ensure remaining 4 msgs end up on _synchronousQueue
-        // Thread.sleep(1000);
+        Thread.sleep(1000);
 
         // Set the message listener and wait for the messages to come in.
         _consumer.setMessageListener(this);



Mime
View raw message