Author: cctrieloff
Date: Mon Aug 27 08:25:17 2007
New Revision: 570152
URL: http://svn.apache.org/viewvc?rev=570152&view=rev
Log:
- cache the exchange on a given Channel
Modified:
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerChannel.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerChannel.h
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerChannel.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerChannel.cpp?rev=570152&r1=570151&r2=570152&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerChannel.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerChannel.cpp Mon Aug 27
08:25:17 2007
@@ -335,15 +335,25 @@
}
}
+
+
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()));
}
}
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerChannel.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerChannel.h?rev=570152&r1=570151&r2=570152&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerChannel.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerChannel.h Mon Aug 27
08:25:17 2007
@@ -74,6 +74,7 @@
bool blocked;
bool windowing;
uint32_t msgCredit;
+
uint32_t byteCredit;
public:
@@ -116,6 +117,10 @@
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);