Skip to content

Commit 51569c4

Browse files
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 bdf3cfb commit 51569c4

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
@@ -275,17 +275,20 @@ list_for_source(SrcName) ->
275275
-spec list_for_destination
276276
(rabbit_types:binding_destination()) -> bindings().
277277

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

290293
implicit_bindings(VHostPath) ->
291294
DstQueues = rabbit_amqqueue:list_names(VHostPath),

0 commit comments

Comments
 (0)