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 2016/04/29 16:16:43 UTC

svn commit: r1741635 - in /qpid/trunk/qpid/cpp/src: qpid/broker/PriorityQueue.cpp tests/MessagingSessionTests.cpp

Author: gsim
Date: Fri Apr 29 14:16:42 2016
New Revision: 1741635

URL: http://svn.apache.org/viewvc?rev=1741635&view=rev
Log:
QPID-7240: use protper cursor type when purging priority levels

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/PriorityQueue.cpp
    qpid/trunk/qpid/cpp/src/tests/MessagingSessionTests.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/PriorityQueue.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/PriorityQueue.cpp?rev=1741635&r1=1741634&r2=1741635&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/PriorityQueue.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/PriorityQueue.cpp Fri Apr 29 14:16:42 2016
@@ -77,7 +77,7 @@ Message* PriorityQueue::next(QueueCursor
 {
     boost::shared_ptr<PriorityContext> ctxt = boost::dynamic_pointer_cast<PriorityContext>(cursor.context);
     if (!ctxt) {
-        ctxt = boost::shared_ptr<PriorityContext>(new PriorityContext(levels, CONSUMER));
+        ctxt = boost::shared_ptr<PriorityContext>(new PriorityContext(levels, cursor.type));
         cursor.context = ctxt;
     }
     if (cursor.type == REPLICATOR) {

Modified: qpid/trunk/qpid/cpp/src/tests/MessagingSessionTests.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/MessagingSessionTests.cpp?rev=1741635&r1=1741634&r2=1741635&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/MessagingSessionTests.cpp (original)
+++ qpid/trunk/qpid/cpp/src/tests/MessagingSessionTests.cpp Fri Apr 29 14:16:42 2016
@@ -1562,6 +1562,46 @@ QPID_AUTO_TEST_CASE(testClientExpiration
     BOOST_CHECK_EQUAL(b_count, 50);
 }
 
+QPID_AUTO_TEST_CASE(testPriorityRingEviction)
+{
+    MessagingFixture fix;
+    std::string queue("queue; {create:always, node:{x-declare:{auto-delete:True, arguments:{qpid.priorities:10, qpid.max_count:5, qpid.policy_type:ring}}}}");
+    Sender sender = fix.session.createSender(queue);
+    Receiver receiver = fix.session.createReceiver(queue);
+    std::vector<Message> acquired;
+    for (uint i = 0; i < 5; ++i) {
+        Message msg((boost::format("msg_%1%") % (i+1)).str());
+        sender.send(msg);
+    }
+    //fetch but don't acknowledge messages, leaving them in acquired state
+    for (uint i = 0; i < 5; ++i) {
+        Message msg;
+        BOOST_CHECK(receiver.fetch(msg, Duration::IMMEDIATE));
+        BOOST_CHECK_EQUAL(msg.getContent(), (boost::format("msg_%1%") % (i+1)).str());
+        acquired.push_back(msg);
+    }
+    //send 5 more messages to the queue, which should cause all the
+    //acquired messages to be dropped
+    for (uint i = 5; i < 10; ++i) {
+        Message msg((boost::format("msg_%1%") % (i+1)).str());
+        sender.send(msg);
+    }
+    //now release the acquired messages, which should have been evicted...
+    for (std::vector<Message>::iterator i = acquired.begin(); i != acquired.end(); ++i) {
+        fix.session.release(*i);
+    }
+    acquired.clear();
+    //and check that the newest five are received
+    for (uint i = 5; i < 10; ++i) {
+        Message msg;
+        BOOST_CHECK(receiver.fetch(msg, Duration::IMMEDIATE));
+        BOOST_CHECK_EQUAL(msg.getContent(), (boost::format("msg_%1%") % (i+1)).str());
+        acquired.push_back(msg);
+    }
+    Message msg;
+    BOOST_CHECK(!receiver.fetch(msg, Duration::IMMEDIATE));
+}
+
 QPID_AUTO_TEST_SUITE_END()
 
 }} // namespace qpid::tests



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org