diff options
| author | Gordon Sim <gsim@apache.org> | 2007-05-17 11:03:55 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2007-05-17 11:03:55 +0000 |
| commit | 9a6c0d41b19744c8e4dc4711d13a5a0afa2f7ed2 (patch) | |
| tree | 539a8102197fa119c7efb77056841932e2eb5c1a /cpp/src/qpid/broker/TopicExchange.cpp | |
| parent | decfd77364e211bc8f8784e15f54e06a79e16675 (diff) | |
| download | qpid-python-9a6c0d41b19744c8e4dc4711d13a5a0afa2f7ed2.tar.gz | |
Changes to support durable exchanges.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@538872 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker/TopicExchange.cpp')
| -rw-r--r-- | cpp/src/qpid/broker/TopicExchange.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/cpp/src/qpid/broker/TopicExchange.cpp b/cpp/src/qpid/broker/TopicExchange.cpp index f29dfc38ba..4ad1607aa2 100644 --- a/cpp/src/qpid/broker/TopicExchange.cpp +++ b/cpp/src/qpid/broker/TopicExchange.cpp @@ -116,24 +116,39 @@ bool TopicPattern::match(const Tokens& target) const } TopicExchange::TopicExchange(const string& _name) : Exchange(_name) { } +TopicExchange::TopicExchange(const std::string& _name, bool _durable, const FieldTable& _args) : Exchange(_name, _durable, _args) {} -void TopicExchange::bind(Queue::shared_ptr queue, const string& routingKey, const FieldTable* /*args*/){ + +bool TopicExchange::bind(Queue::shared_ptr queue, const string& routingKey, const FieldTable* /*args*/){ Monitor::ScopedLock l(lock); TopicPattern routingPattern(routingKey); - bindings[routingPattern].push_back(queue); + if (isBound(queue, routingPattern)) { + return false; + } else { + bindings[routingPattern].push_back(queue); + return true; + } } -void TopicExchange::unbind(Queue::shared_ptr queue, const string& routingKey, const FieldTable* /*args*/){ +bool TopicExchange::unbind(Queue::shared_ptr queue, const string& routingKey, const FieldTable* /*args*/){ Monitor::ScopedLock l(lock); BindingMap::iterator bi = bindings.find(TopicPattern(routingKey)); Queue::vector& qv(bi->second); - if (bi == bindings.end()) return; + if (bi == bindings.end()) return false; Queue::vector::iterator q = find(qv.begin(), qv.end(), queue); - if(q == qv.end()) return; + if(q == qv.end()) return false; qv.erase(q); if(qv.empty()) bindings.erase(bi); + return true; } +bool TopicExchange::isBound(Queue::shared_ptr queue, TopicPattern& pattern) +{ + BindingMap::iterator bi = bindings.find(pattern); + if (bi == bindings.end()) return false; + Queue::vector& qv(bi->second); + return find(qv.begin(), qv.end(), queue) != qv.end(); +} void TopicExchange::route(Deliverable& msg, const string& routingKey, const FieldTable* /*args*/){ Monitor::ScopedLock l(lock); |
