summaryrefslogtreecommitdiff
path: root/cpp/lib/broker/BrokerQueue.cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2006-12-05 17:43:00 +0000
committerGordon Sim <gsim@apache.org>2006-12-05 17:43:00 +0000
commit722b16a1a7bbde82a4cd82c99a0e29d31d0545ca (patch)
tree4866c7dc7e3e85a9f62ce6512ee1a569a4882e20 /cpp/lib/broker/BrokerQueue.cpp
parent96aa6c6e76ffa946192778d69d36d4c372a0de7b (diff)
downloadqpid-python-722b16a1a7bbde82a4cd82c99a0e29d31d0545ca.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/qpid@482723 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/lib/broker/BrokerQueue.cpp')
-rw-r--r--cpp/lib/broker/BrokerQueue.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/cpp/lib/broker/BrokerQueue.cpp b/cpp/lib/broker/BrokerQueue.cpp
index 26857b6d31..b0e1f20b01 100644
--- a/cpp/lib/broker/BrokerQueue.cpp
+++ b/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();
+}