Skip to content

Commit 4209f3f

Browse files
committed
Set durable annotation for AMQP messages
This is similar to #11057 What? For incoming AMQP messages, always set the durable message container annotation. Why? Even though defaulting to durable=true when no durable annotation is set, as prior to this commit, is good enough, explicitly setting the durable annotation makes the code a bit more future proof and maintainable going forward in 4.0 where we will rely more on the durable annotation because AMQP 1.0 message headers will be omitted in classic and quorum queues. The performance impact of always setting the durable annotation is negligible.
1 parent b721b1a commit 4209f3f

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

deps/rabbit/src/mc_amqp.erl

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
]).
1818

1919
-import(rabbit_misc,
20-
[maps_put_truthy/3,
21-
maps_put_falsy/3
22-
]).
20+
[maps_put_truthy/3]).
2321

2422
-type message_section() ::
2523
#'v1_0.header'{} |
@@ -185,8 +183,6 @@ get_property(durable, Msg) ->
185183
#msg_body_encoded{header = #'v1_0.header'{durable = Durable}}
186184
when is_boolean(Durable) ->
187185
Durable;
188-
#msg_body_encoded{header = #'v1_0.header'{durable = {boolean, Durable}}} ->
189-
Durable;
190186
_ ->
191187
%% fallback in case the source protocol was old AMQP 0.9.1
192188
case message_annotation(<<"x-basic-delivery-mode">>, Msg, undefined) of
@@ -644,17 +640,16 @@ essential_properties(#msg_body_encoded{message_annotations = MA} = Msg) ->
644640
_ ->
645641
undefined
646642
end,
647-
Anns = maps_put_falsy(
648-
?ANN_DURABLE, Durable,
643+
Anns0 = #{?ANN_DURABLE => Durable},
644+
Anns = maps_put_truthy(
645+
?ANN_PRIORITY, Priority,
649646
maps_put_truthy(
650-
?ANN_PRIORITY, Priority,
647+
?ANN_TIMESTAMP, Timestamp,
651648
maps_put_truthy(
652-
?ANN_TIMESTAMP, Timestamp,
649+
ttl, Ttl,
653650
maps_put_truthy(
654-
ttl, Ttl,
655-
maps_put_truthy(
656-
deaths, Deaths,
657-
#{}))))),
651+
deaths, Deaths,
652+
Anns0)))),
658653
case MA of
659654
[] ->
660655
Anns;

0 commit comments

Comments
 (0)