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/qpid/broker/BrokerChannel.cpp | |
| 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/qpid/broker/BrokerChannel.cpp')
| -rw-r--r-- | cpp/src/qpid/broker/BrokerChannel.cpp | 20 |
1 files changed, 15 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())); } } |
