diff options
| author | Alan Conway <aconway@apache.org> | 2012-04-17 15:12:15 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2012-04-17 15:12:15 +0000 |
| commit | 413fba8d12f8c6b676af7f47cd5babcfc9d1020b (patch) | |
| tree | d05ebd95ba9f3c5dced17706e3791bccd029704c /cpp/src/qpid/broker/Queue.cpp | |
| parent | fd83590a267c563f8cabdbf32f2dc221a7d322db (diff) | |
| download | qpid-python-413fba8d12f8c6b676af7f47cd5babcfc9d1020b.tar.gz | |
QPID-3950: Allow browsing of queues with exclusive subscriptions
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1327135 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker/Queue.cpp')
| -rw-r--r-- | cpp/src/qpid/broker/Queue.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/cpp/src/qpid/broker/Queue.cpp b/cpp/src/qpid/broker/Queue.cpp index a223392e2e..4f114fa0a7 100644 --- a/cpp/src/qpid/broker/Queue.cpp +++ b/cpp/src/qpid/broker/Queue.cpp @@ -154,6 +154,7 @@ Queue::Queue(const string& _name, bool _autodelete, store(_store), owner(_owner), consumerCount(0), + browserCount(0), exclusive(0), noLocal(false), persistLastNode(false), @@ -523,17 +524,27 @@ void Queue::consume(Consumer::shared_ptr c, bool requestExclusive){ assertClusterSafe(); { Mutex::ScopedLock locker(messageLock); - if(exclusive) { - throw ResourceLockedException( - QPID_MSG("Queue " << getName() << " has an exclusive consumer. No more consumers allowed.")); - } else if(requestExclusive) { - if(consumerCount) { + // NOTE: consumerCount is actually a count of all + // subscriptions, both acquiring and non-acquiring (browsers). + // Check for exclusivity of acquiring consumers. + size_t acquiringConsumers = consumerCount - browserCount; + if (c->preAcquires()) { + if(exclusive) { throw ResourceLockedException( - QPID_MSG("Queue " << getName() << " already has consumers. Exclusive access denied.")); - } else { - exclusive = c->getSession(); + QPID_MSG("Queue " << getName() + << " has an exclusive consumer. No more consumers allowed.")); + } else if(requestExclusive) { + if(acquiringConsumers) { + throw ResourceLockedException( + QPID_MSG("Queue " << getName() + << " already has consumers. Exclusive access denied.")); + } else { + exclusive = c->getSession(); + } } } + else + browserCount++; consumerCount++; //reset auto deletion timer if necessary if (autoDeleteTimeout && autoDeleteTask) { @@ -550,6 +561,7 @@ void Queue::cancel(Consumer::shared_ptr c){ { Mutex::ScopedLock locker(messageLock); consumerCount--; + if (!c->preAcquires()) browserCount--; if(exclusive) exclusive = 0; observeConsumerRemove(*c, locker); } |
