You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2008/02/18 10:24:02 UTC

svn commit: r628659 - in /incubator/qpid/trunk/qpid: cpp/src/qpid/broker/DeliveryRecord.cpp python/tests_0-10/message.py

Author: gsim
Date: Mon Feb 18 01:23:54 2008
New Revision: 628659

URL: http://svn.apache.org/viewvc?rev=628659&view=rev
Log:
Requests to release a message that has not been acquired should be ignored.


Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/DeliveryRecord.cpp
    incubator/qpid/trunk/qpid/python/tests_0-10/message.py

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/DeliveryRecord.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/DeliveryRecord.cpp?rev=628659&r1=628658&r2=628659&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/DeliveryRecord.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/DeliveryRecord.cpp Mon Feb 18 01:23:54 2008
@@ -104,7 +104,7 @@
 
 void DeliveryRecord::release() 
 {
-    if (!confirmed) {
+    if (acquired && !confirmed) {
         queue->requeue(msg);
         acquired = false;
     }

Modified: incubator/qpid/trunk/qpid/python/tests_0-10/message.py
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/tests_0-10/message.py?rev=628659&r1=628658&r2=628659&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/tests_0-10/message.py (original)
+++ incubator/qpid/trunk/qpid/python/tests_0-10/message.py Mon Feb 18 01:23:54 2008
@@ -763,6 +763,48 @@
         #check all 'browsed' messages are still on the queue
         self.assertEqual(5, channel.queue_query(queue="q").message_count)
 
+    def test_release_unacquired(self):
+        channel = self.channel
+
+        #create queue
+        self.queue_declare(queue = "q", exclusive=True, auto_delete=True, durable=True)
+
+        #send message
+        channel.message_transfer(content=Content(properties={'routing_key' : "q", 'delivery_mode':2}, body = "my-message"))
+
+        #create two 'browsers'
+        channel.message_subscribe(queue = "q", destination = "a", confirm_mode = 1, acquire_mode=1)
+        channel.message_flow(unit = 1, value = 0xFFFFFFFF, destination = "a")
+        channel.message_flow(unit = 0, value = 10, destination = "a")
+        queueA = self.client.queue("a")
+
+        channel.message_subscribe(queue = "q", destination = "b", confirm_mode = 1, acquire_mode=1)
+        channel.message_flow(unit = 1, value = 0xFFFFFFFF, destination = "b")
+        channel.message_flow(unit = 0, value = 10, destination = "b")
+        queueB = self.client.queue("b")
+        
+        #have each browser release the message
+        msgA = queueA.get(timeout = 1)
+        channel.message_release([msgA.command_id, msgA.command_id])
+
+        msgB = queueB.get(timeout = 1)
+        channel.message_release([msgB.command_id, msgB.command_id])
+        
+        #cancel browsers
+        channel.message_cancel(destination = "a")
+        channel.message_cancel(destination = "b")
+        
+        #create consumer
+        channel.message_subscribe(queue = "q", destination = "c", confirm_mode = 1, acquire_mode=0)
+        channel.message_flow(unit = 1, value = 0xFFFFFFFF, destination = "c")
+        channel.message_flow(unit = 0, value = 10, destination = "c")
+        queueC = self.client.queue("c")
+        #consume the message then ack it
+        msgC = queueC.get(timeout = 1)
+        msgC.complete()
+        #ensure there are no other messages
+        self.assertEmpty(queueC)
+
     def test_no_size(self):
         self.queue_declare(queue = "q", exclusive=True, auto_delete=True)