From 7e080f3ef470dcec94079f3d7e59edbf4c791844 Mon Sep 17 00:00:00 2001 From: Kenneth Anthony Giusti Date: Tue, 6 Apr 2010 18:18:44 +0000 Subject: QPID-2482: prevent duplication of messages that match multiple binding keys on a topic exchange git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@931257 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/broker/TopicExchange.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'cpp/src/qpid/broker/TopicExchange.cpp') diff --git a/cpp/src/qpid/broker/TopicExchange.cpp b/cpp/src/qpid/broker/TopicExchange.cpp index 6e53ef5fd2..66ace42cfa 100644 --- a/cpp/src/qpid/broker/TopicExchange.cpp +++ b/cpp/src/qpid/broker/TopicExchange.cpp @@ -19,6 +19,7 @@ * */ #include "qpid/broker/TopicExchange.h" +#include "qpid/log/Statement.h" #include @@ -214,6 +215,8 @@ bool TopicExchange::bind(Queue::shared_ptr queue, const string& routingKey, cons if (mgmtExchange != 0) { mgmtExchange->inc_bindingCount(); } + QPID_LOG(debug, "Bound [" << routingPattern << "] to queue " << queue->getName() + << " (origin=" << fedOrigin << ")"); } } else if (fedOp == fedOpUnbind) { { @@ -274,6 +277,7 @@ bool TopicExchange::unbind(Queue::shared_ptr queue, const string& constRoutingKe if (mgmtExchange != 0) { mgmtExchange->dec_bindingCount(); } + QPID_LOG(debug, "Unbound [" << routingKey << "] from queue " << queue->getName()); if (propagate) propagateFedOp(routingKey, string(), fedOpUnbind, string()); @@ -294,16 +298,19 @@ bool TopicExchange::isBound(Queue::shared_ptr queue, const string& pattern) void TopicExchange::route(Deliverable& msg, const string& routingKey, const FieldTable* /*args*/) { - Binding::vector mb; BindingList b(new std::vector >); PreRoute pr(msg, this); + std::set qSet; { RWlock::ScopedRlock l(lock); for (BindingMap::iterator i = bindings.begin(); i != bindings.end(); ++i) { if (match(i->first, routingKey)) { Binding::vector& qv(i->second.bindingVector); for(Binding::vector::iterator j = qv.begin(); j != qv.end(); j++){ - b->push_back(*j); + // do not duplicate queues on the binding list + if (qSet.insert(j->get()->queue->getName()).second) { + b->push_back(*j); + } } } } -- cgit v1.2.1