diff options
author | Kenneth Anthony Giusti <kgiusti@apache.org> | 2012-02-02 23:46:35 +0000 |
---|---|---|
committer | Kenneth Anthony Giusti <kgiusti@apache.org> | 2012-02-02 23:46:35 +0000 |
commit | 5e8ccd2a9ab02c167d96b61bc85af3949351dd22 (patch) | |
tree | fa9acd0f1195f3615e7e1ac5694b9320d86646d8 | |
parent | c73814f2a538edbef14369964a66dd36d6241996 (diff) | |
download | qpid-python-5e8ccd2a9ab02c167d96b61bc85af3949351dd22.tar.gz |
QPID-3804: do not skip released grouped messages
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1239939 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | cpp/src/qpid/broker/MessageGroupManager.cpp | 2 | ||||
-rw-r--r-- | tests/src/py/qpid_tests/broker_0_10/msg_groups.py | 49 |
2 files changed, 50 insertions, 1 deletions
diff --git a/cpp/src/qpid/broker/MessageGroupManager.cpp b/cpp/src/qpid/broker/MessageGroupManager.cpp index 7054ef0310..0aef732e54 100644 --- a/cpp/src/qpid/broker/MessageGroupManager.cpp +++ b/cpp/src/qpid/broker/MessageGroupManager.cpp @@ -210,7 +210,7 @@ bool MessageGroupManager::nextConsumableMessage( Consumer::shared_ptr& c, Queued next.position = c->getPosition(); if (!freeGroups.empty()) { const framing::SequenceNumber& nextFree = freeGroups.begin()->first; - if (nextFree < next.position) { // a free message is older than current + if (nextFree <= next.position) { // take oldest free next.position = nextFree; --next.position; } diff --git a/tests/src/py/qpid_tests/broker_0_10/msg_groups.py b/tests/src/py/qpid_tests/broker_0_10/msg_groups.py index 99d11151e8..4d6d77a46f 100644 --- a/tests/src/py/qpid_tests/broker_0_10/msg_groups.py +++ b/tests/src/py/qpid_tests/broker_0_10/msg_groups.py @@ -1068,6 +1068,55 @@ class MultiConsumerMsgGroupTests(Base): self.qmf_session.delBroker(self.qmf_broker) + def test_transaction_order(self): + """ Verify that rollback does not reorder the messages with respect to + the consumer (QPID-3804) + """ + snd = self.ssn.sender("msg-group-q; {create:always, delete:sender," + + " node: {x-declare: {arguments:" + + " {'qpid.group_header_key':'THE-GROUP'," + + "'qpid.shared_msg_group':1}}}}") + + groups = ["A","B","A"] + messages = [Message(content={}, properties={"THE-GROUP": g}) for g in groups] + index = 0 + for m in messages: + m.content['index'] = index + index += 1 + snd.send(m) + + s1 = self.conn.session(transactional=True) + c1 = s1.receiver("msg-group-q", options={"capacity":0}) + + # C1 gets group A + m1 = c1.fetch(0) + assert m1.properties['THE-GROUP'] == 'A' + assert m1.content['index'] == 0 + s1.acknowledge(m1) + + s1.rollback() # release A back to the queue + + # the order should be preserved as follows: + + m1 = c1.fetch(0) + assert m1.properties['THE-GROUP'] == 'A' + assert m1.content['index'] == 0 + + m2 = c1.fetch(0) + assert m2.properties['THE-GROUP'] == 'B' + assert m2.content['index'] == 1 + + m3 = c1.fetch(0) + assert m3.properties['THE-GROUP'] == 'A' + assert m3.content['index'] == 2 + + s1.commit() + + c1.close() + s1.close() + snd.close() + + class StickyConsumerMsgGroupTests(Base): """ Tests for the behavior of sticky-consumer message groups. These tests |