diff options
author | Carl C. Trieloff <cctrieloff@apache.org> | 2007-08-27 15:25:17 +0000 |
---|---|---|
committer | Carl C. Trieloff <cctrieloff@apache.org> | 2007-08-27 15:25:17 +0000 |
commit | 366b7287350d47f788a0d1af1a1bf73328e4ec1f (patch) | |
tree | e3d5d5385124741e76ac8df9b9bc18be49e98f01 /cpp/src | |
parent | ee9d046b17a1b03140bbc3f338dc7c11abf1412e (diff) | |
download | qpid-python-366b7287350d47f788a0d1af1a1bf73328e4ec1f.tar.gz |
- cache the exchange on a given Channel
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@570152 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/qpid/broker/BrokerChannel.cpp | 20 | ||||
-rw-r--r-- | cpp/src/qpid/broker/BrokerChannel.h | 5 |
2 files changed, 20 insertions, 5 deletions
diff --git a/cpp/src/qpid/broker/BrokerChannel.cpp b/cpp/src/qpid/broker/BrokerChannel.cpp index 0dc4bed661..11d8db73f8 100644 --- a/cpp/src/qpid/broker/BrokerChannel.cpp +++ b/cpp/src/qpid/broker/BrokerChannel.cpp @@ -335,15 +335,25 @@ void Channel::complete(Message::shared_ptr msg) { } } + + void Channel::route(Message::shared_ptr msg, Deliverable& strategy) { - Exchange::shared_ptr exchange = connection.broker.getExchanges().get(msg->getExchange()); - assert(exchange.get()); - exchange->route(strategy, msg->getRoutingKey(), &(msg->getApplicationHeaders())); + + std::string routeToExchangeName = msg->getExchange(); + // cache the exchange lookup + if (!cacheExchange.get() || cacheExchangeName != routeToExchangeName){ + cacheExchangeName = routeToExchangeName; + cacheExchange = connection.broker.getExchanges().get(routeToExchangeName); + } + + assert(cacheExchange.get()); + cacheExchange->route(strategy, msg->getRoutingKey(), &(msg->getApplicationHeaders())); + if (!strategy.delivered) { //TODO:if reject-unroutable, then reject //else route to alternate exchange - if (exchange->getAlternate()) { - exchange->getAlternate()->route(strategy, msg->getRoutingKey(), &(msg->getApplicationHeaders())); + if (cacheExchange->getAlternate()) { + cacheExchange->getAlternate()->route(strategy, msg->getRoutingKey(), &(msg->getApplicationHeaders())); } } diff --git a/cpp/src/qpid/broker/BrokerChannel.h b/cpp/src/qpid/broker/BrokerChannel.h index 021110cf8c..fcfcd73679 100644 --- a/cpp/src/qpid/broker/BrokerChannel.h +++ b/cpp/src/qpid/broker/BrokerChannel.h @@ -74,6 +74,7 @@ class Channel : public CompletionHandler bool blocked; bool windowing; uint32_t msgCredit; + uint32_t byteCredit; public: @@ -116,6 +117,10 @@ class Channel : public CompletionHandler MessageBuilder messageBuilder;//builder for in-progress message bool opened; bool flowActive; + + std::string cacheExchangeName; // pair holds last exchange used for routing + Exchange::shared_ptr cacheExchange; + void route(Message::shared_ptr msg, Deliverable& strategy); void complete(Message::shared_ptr msg);// completion handler for MessageBuilder void record(const DeliveryRecord& delivery); |