Skip to content

Commit 66d8d7c

Browse files
kjnilssonmichaelklishin
authored andcommitted
Logger exchange should take message_containers feature flag into account
To avoid creating mc wrapped messages before the feature flag has been enabled.
1 parent 2c4e5de commit 66d8d7c

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

deps/rabbit/src/rabbit_channel.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ handle_method(#'basic.publish'{exchange = ExchangeNameBin,
12641264
Opts = maps_put_truthy(flow, Flow, #{correlation => SeqNo, mandatory => Mandatory}),
12651265
{Opts, State0#ch{publish_seqno = SeqNo + 1}}
12661266
end,
1267-
% rabbit_feature_flags:is_enabled(message_containers),
1267+
12681268
case mc_amqpl:message(ExchangeName,
12691269
RoutingKey,
12701270
DecodedContent) of

deps/rabbit/src/rabbit_logger_exchange_h.erl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,16 @@ do_log(LogEvent, #{config := #{exchange := Exchange}} = Config) ->
5454
PBasic = log_event_to_amqp_msg(LogEvent, Config),
5555
Body = try_format_body(LogEvent, Config),
5656
Content = rabbit_basic:build_content(PBasic, Body),
57-
Anns = #{exchange => Exchange#resource.name,
58-
routing_keys => [RoutingKey]},
59-
Msg = mc:init(mc_amqpl, Content, Anns),
60-
case rabbit_queue_type:publish_at_most_once(Exchange, Msg) of
61-
ok -> ok;
62-
{error, not_found} -> ok
57+
58+
case mc_amqpl:message(Exchange, RoutingKey, Content) of
59+
{ok, Msg} ->
60+
case rabbit_queue_type:publish_at_most_once(Exchange, Msg) of
61+
ok -> ok;
62+
{error, not_found} -> ok
63+
end;
64+
{error, _Reason} ->
65+
%% it would be good to log this error but can we?
66+
ok
6367
end.
6468

6569
removing_handler(Config) ->

0 commit comments

Comments
 (0)