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 | 3a636ee8dcef14d71b2ac28e044672e2000e74c3 (patch) | |
| tree | 49c9aaa4ec7d8ff907dd1ee952ffcb4f3f4eb41e /qpid/cpp | |
| parent | 6888f1bec4682e1a444772cc3d17f4e59ba3c351 (diff) | |
| download | qpid-python-3a636ee8dcef14d71b2ac28e044672e2000e74c3.tar.gz | |
- cache the exchange on a given Channel
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@570152 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp')
| -rw-r--r-- | qpid/cpp/src/qpid/broker/BrokerChannel.cpp | 20 | ||||
| -rw-r--r-- | qpid/cpp/src/qpid/broker/BrokerChannel.h | 5 |
2 files changed, 20 insertions, 5 deletions
diff --git a/qpid/cpp/src/qpid/broker/BrokerChannel.cpp b/qpid/cpp/src/qpid/broker/BrokerChannel.cpp index 0dc4bed661..11d8db73f8 100644 --- a/qpid/cpp/src/qpid/broker/BrokerChannel.cpp +++ b/qpid/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/qpid/cpp/src/qpid/broker/BrokerChannel.h b/qpid/cpp/src/qpid/broker/BrokerChannel.h index 021110cf8c..fcfcd73679 100644 --- a/qpid/cpp/src/qpid/broker/BrokerChannel.h +++ b/qpid/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); |
