diff options
| author | Ben Hood <0x6e6562@gmail.com> | 2008-08-27 00:52:02 +0100 |
|---|---|---|
| committer | Ben Hood <0x6e6562@gmail.com> | 2008-08-27 00:52:02 +0100 |
| commit | 04cac0a920ed6d722ec4782e6077c38e0d533e1c (patch) | |
| tree | ce28e29cb4940c4215496bfae247f7ad538aa337 | |
| parent | 6c1af42f9eebd553c74ae9a006c68d543ade00fa (diff) | |
| download | rabbitmq-server-git-04cac0a920ed6d722ec4782e6077c38e0d533e1c.tar.gz | |
All of Qpid's tests now pass
| -rw-r--r-- | src/rabbit_exchange.erl | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index fadd2844ef..89580a0e35 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -182,11 +182,27 @@ simple_publish(Mandatory, Immediate, route(#exchange{name = Name, type = topic}, RoutingKey) -> route_internal(Name, RoutingKey, fun topic_matches/2); +% This matches for the direct exchanges and tries to short-cut the routing table +% for the default queue if that is what the user supplied +route(#exchange{name = Name = #resource{name = <<>>}, type = direct}, RoutingKey) -> + case route_internal(Name, RoutingKey) of + [] -> route_internal(Name, RoutingKey, fun(X,Y) -> X == Y end); + Other -> Other + end; + route(#exchange{name = Name, type = Type}, RoutingKey) -> route_internal(Name, RoutingKey, fun(X,Y) -> X == Y end). % This returns a list of QPids to route to. % Maybe this should be handled by a cursor instead. +% This routes directly to queues, avoiding any lookup of routes +route_internal(#resource{name = <<>>, virtual_host = VHostPath}, RoutingKey) -> + Query = qlc:q([QPid || #amqqueue{name = Queue, pid = QPid} <- mnesia:table(amqqueue), + Queue == rabbit_misc:r(VHostPath, queue, RoutingKey)]), + mnesia:activity(async_dirty, fun() -> qlc:e(Query) end). + +% This returns a list of QPids to route to. +% Maybe this should be handled by a cursor instead. route_internal(Exchange, RoutingKey, MatchFun) -> Query = qlc:q([QPid || #route{binding = #binding{exchange_name = ExchangeName, queue_name = QueueName, |
