diff options
| -rw-r--r-- | src/rabbit_amqqueue.erl | 26 | ||||
| -rw-r--r-- | src/rabbit_exchange.erl | 25 |
2 files changed, 5 insertions, 46 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index 62d7821245..3d6b85f888 100644 --- a/src/rabbit_amqqueue.erl +++ b/src/rabbit_amqqueue.erl @@ -172,42 +172,16 @@ add_default_binding(#amqqueue{name = QueueName}) -> ok. add_binding(QueueName, ExchangeName, RoutingKey, Arguments) -> - % Since this calls straight through to rabbit_exchange, - % can this exported function be deleted from this module? Binding = #binding{exchange_name = ExchangeName, key = RoutingKey, queue_name = QueueName}, rabbit_misc:execute_mnesia_transaction(fun rabbit_exchange:add_binding/1, [Binding]). - % modify_bindings( - % QueueName, ExchangeName, RoutingKey, Arguments, - % fun (Q, _Spec) -> {ok, Q} end, - % fun (Q, Spec) -> update_bindings( - % Q, Spec, - % fun (S, Specs) -> [S | Specs] end, - % fun rabbit_exchange:add_binding/2) - % end). delete_binding(QueueName, ExchangeName, RoutingKey, Arguments) -> Binding = #binding{exchange_name = ExchangeName, key = RoutingKey, queue_name = QueueName}, rabbit_misc:execute_mnesia_transaction(fun rabbit_exchange:delete_binding/1, [Binding]). - % modify_bindings( - % QueueName, ExchangeName, RoutingKey, Arguments, - % fun (Q, Spec) -> update_bindings( - % Q, Spec, - % fun lists:delete/2, - % fun rabbit_exchange:delete_binding/2) - % end, - % fun (Q, Spec) -> - % %% the following is essentially a no-op, though crucially - % %% it produces {error, not_found} when the exchange does - % %% not exist. - % case rabbit_exchange:delete_binding(Spec, Q) of - % ok -> {error, binding_not_found}; - % Other -> Other - % end - % end). lookup(Name) -> rabbit_misc:dirty_read({amqqueue, Name}). diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index b6a1c84823..06201f8312 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -179,7 +179,7 @@ simple_publish(Mandatory, Immediate, route(#exchange{name = Name, type = topic}, RoutingKey) -> route_internal(Name, RoutingKey, fun topic_matches/2); -route(#exchange{name = Name, type = Type}, RoutingKey) -> +route(#exchange{name = Name}, RoutingKey) -> route_internal(Name, RoutingKey). % This returns a list of QPids to route to. @@ -191,16 +191,9 @@ route_internal(#resource{name = Name, virtual_host = VHostPath}, RoutingKey) -> queue_name = '$3', key = '$4'}}, Guards = [{'==', '$1', Name}, {'==', '$2', VHostPath}, {'==', '$4', RoutingKey}], - - {Time, X} = timer:tc(mnesia,activity,[async_dirty, + lookup_qpids(mnesia:activity(async_dirty, fun() -> mnesia:select(route,[{MatchHead, Guards, ['$3']}]) - end]), - %io:format("First read = ~p~n",[Time]), - lookup_qpids(X). - % lookup_qpids( - % mnesia:activity(async_dirty, - % fun() -> mnesia:select(route,[{MatchHead, Guards, ['$3']}]) - % end)). + end)). % This returns a list of QPids to route to. % Maybe this should be handled by a cursor instead. @@ -220,24 +213,16 @@ lookup_qpids(Queues) -> fun(Key, Acc) -> [#amqqueue{pid = QPid}] = mnesia:read({amqqueue, Key}), [QPid] ++ Acc end, [], Set) end, - %mnesia:activity(async_dirty,Fun). - {Time, X} = timer:tc(mnesia,activity,[async_dirty,Fun]), - %io:format("Second read = ~p~n",[Time]), - X. + mnesia:activity(async_dirty,Fun). % Should all of the route and binding management not be refactored to it's own module % Especially seeing as unbind will have to be implemented for 0.91 ? -delete_routes(Q = #amqqueue{name = Name}) -> +delete_routes(#amqqueue{name = Name}) -> Binding = #binding{queue_name = Name, exchange_name = '_', key = '_'}, {Route, ReverseRoute} = route_with_reverse(Binding), ok = mnesia:delete_object(Route), ok = mnesia:delete_object(ReverseRoute). -delivery_key_for_type(fanout, Name, _RoutingKey) -> - {Name, fanout}; -delivery_key_for_type(_Type, Name, RoutingKey) -> - {Name, RoutingKey}. - % Don't really like this double lookup % It seems very clunky % Can this get refactored to to avoid the duplication of the lookup/1 function? |
