Skip to content

Commit 310ba4e

Browse files
michaelklishinkjnilsson
authored andcommitted
Filter duplicate default exchange binding in rabbit_binding:list_for_destination/1
Follow-up to #1721. Even though the default exchange bindings are deleted at schema migration time, this filtering improves backwards compatibility for mixed version clusters.
1 parent ce07a26 commit 310ba4e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/rabbit_binding.erl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,17 +273,20 @@ list_for_source(SrcName) ->
273273
-spec list_for_destination
274274
(rabbit_types:binding_destination()) -> bindings().
275275

276-
list_for_destination(DstName) ->
277-
implicit_for_destination(DstName) ++
278-
mnesia:async_dirty(
276+
list_for_destination(DstName = #resource{virtual_host = VHostPath}) ->
277+
AllBindings = mnesia:async_dirty(
279278
fun() ->
280279
Route = #route{binding = #binding{destination = DstName,
281280
_ = '_'}},
282281
[reverse_binding(B) ||
283282
#reverse_route{reverse_binding = B} <-
284283
mnesia:match_object(rabbit_reverse_route,
285284
reverse_route(Route), read)]
286-
end).
285+
end),
286+
Filtered = lists:filter(fun(#binding{source = S}) ->
287+
S =/= ?DEFAULT_EXCHANGE(VHostPath)
288+
end, AllBindings),
289+
implicit_for_destination(DstName) ++ Filtered.
287290

288291
implicit_bindings(VHostPath) ->
289292
DstQueues = rabbit_amqqueue:list_names(VHostPath),

0 commit comments

Comments
 (0)