diff options
| author | Gordon Sim <gsim@apache.org> | 2006-12-05 17:43:00 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2006-12-05 17:43:00 +0000 |
| commit | 3259d875114106fe2543e02d43b9562185de8226 (patch) | |
| tree | 04349ee62fd6d350a980870d8c6d1d88b8eac194 /qpid/cpp/lib/broker/BrokerQueue.cpp | |
| parent | 1dcc01e62d7ef427aefc9440ba3e11f0831ef1be (diff) | |
| download | qpid-python-3259d875114106fe2543e02d43b9562185de8226.tar.gz | |
Allow settings to be set and persisted for queues.
Define policy based on these settings.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@482723 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/lib/broker/BrokerQueue.cpp')
| -rw-r--r-- | qpid/cpp/lib/broker/BrokerQueue.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/qpid/cpp/lib/broker/BrokerQueue.cpp b/qpid/cpp/lib/broker/BrokerQueue.cpp index 26857b6d31..b0e1f20b01 100644 --- a/qpid/cpp/lib/broker/BrokerQueue.cpp +++ b/qpid/cpp/lib/broker/BrokerQueue.cpp @@ -161,12 +161,14 @@ u_int32_t Queue::purge(){ } void Queue::pop(){ - messages.pop(); + if (policy.get()) policy->dequeued(messages.front(), store); + messages.pop(); } void Queue::push(Message::shared_ptr& msg){ queueing = true; messages.push(msg); + if (policy.get()) policy->enqueued(messages.front(), store); } u_int32_t Queue::getMessageCount() const{ @@ -206,24 +208,17 @@ namespace void Queue::create(const FieldTable& settings) { - //Note: currently field table only contain signed 32 bit ints, which - // restricts the values that can be set on the queue policy. - u_int32_t maxCount(0); - try { - maxCount = settings.getInt(qpidMaxSize); - } catch (FieldNotFoundException& ignore) { - } - u_int32_t maxSize(0); - try { - maxSize = settings.getInt(qpidMaxCount); - } catch (FieldNotFoundException& ignore) { - } - if (maxCount || maxSize) { - setPolicy(std::auto_ptr<QueuePolicy>(new QueuePolicy(maxCount, maxSize))); - } - if (store) { - store->create(*this); + store->create(*this, settings); + } + configure(settings); +} + +void Queue::configure(const FieldTable& settings) +{ + QueuePolicy* _policy = new QueuePolicy(settings); + if (_policy->getMaxCount() || _policy->getMaxSize()) { + setPolicy(std::auto_ptr<QueuePolicy>(_policy)); } } @@ -238,3 +233,8 @@ void Queue::setPolicy(std::auto_ptr<QueuePolicy> _policy) { policy = _policy; } + +const QueuePolicy* const Queue::getPolicy() +{ + return policy.get(); +} |
