Skip to content

Commit e2a1136

Browse files
committed
Disallow transient entities in RabbitMQ AMQP 1.0 Erlang client
Transient (i.e. `durable=false`) exchanges and queues are deprecated. Khepri will store all entities durably. (Even exclusive queues will be stored durably. Exclusive queues are still deleted when the declaring connection is closed.) Similar to how the RabbitMQ AMQP 1.0 Java client already disallows the creation of transient exchanges and queues, this commit will prohibit the declaration of transient exchanges and queues in the RabbitMQ AMQP 1.0 Erlang client starting with RabbitMQ 4.1.
1 parent 96ebce8 commit e2a1136

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

deps/rabbitmq_amqp_client/src/rabbitmq_amqp_client.erl

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,11 @@
5050
replicas => [binary()],
5151
leader => binary()}.
5252

53-
-type queue_properties() :: #{durable => boolean(),
54-
exclusive => boolean(),
53+
-type queue_properties() :: #{exclusive => boolean(),
5554
auto_delete => boolean(),
5655
arguments => arguments()}.
5756

5857
-type exchange_properties() :: #{type => binary(),
59-
durable => boolean(),
6058
auto_delete => boolean(),
6159
internal => boolean(),
6260
arguments => arguments()}.
@@ -161,9 +159,7 @@ get_queue(LinkPair, QueueName) ->
161159
{ok, queue_info()} | {error, term()}.
162160
declare_queue(LinkPair, QueueName, QueueProperties) ->
163161
Body0 = maps:fold(
164-
fun(durable, V, L) when is_boolean(V) ->
165-
[{{utf8, <<"durable">>}, {boolean, V}} | L];
166-
(exclusive, V, L) when is_boolean(V) ->
162+
fun(exclusive, V, L) when is_boolean(V) ->
167163
[{{utf8, <<"exclusive">>}, {boolean, V}} | L];
168164
(auto_delete, V, L) when is_boolean(V) ->
169165
[{{utf8, <<"auto_delete">>}, {boolean, V}} | L];
@@ -341,8 +337,6 @@ declare_exchange(LinkPair, ExchangeName, ExchangeProperties) ->
341337
Body0 = maps:fold(
342338
fun(type, V, L) when is_binary(V) ->
343339
[{{utf8, <<"type">>}, {utf8, V}} | L];
344-
(durable, V, L) when is_boolean(V) ->
345-
[{{utf8, <<"durable">>}, {boolean, V}} | L];
346340
(auto_delete, V, L) when is_boolean(V) ->
347341
[{{utf8, <<"auto_delete">>}, {boolean, V}} | L];
348342
(internal, V, L) when is_boolean(V) ->

deps/rabbitmq_amqp_client/test/management_SUITE.erl

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ all_management_operations(Config) ->
127127
Init = {_, LinkPair = #link_pair{session = Session}} = init(Config),
128128

129129
QName = <<"my 🐇"/utf8>>,
130-
QProps = #{durable => true,
131-
exclusive => false,
130+
QProps = #{exclusive => false,
132131
auto_delete => false,
133132
arguments => #{<<"x-queue-type">> => {utf8, <<"quorum">>}}},
134133
{ok, QInfo} = rabbitmq_amqp_client:declare_queue(LinkPair, QName, QProps),
@@ -193,7 +192,6 @@ all_management_operations(Config) ->
193192

194193
XName = <<"my fanout exchange 🥳"/utf8>>,
195194
XProps = #{type => <<"fanout">>,
196-
durable => false,
197195
auto_delete => true,
198196
internal => false,
199197
arguments => #{<<"x-📥"/utf8>> => {utf8, <<"📮"/utf8>>}}},
@@ -202,7 +200,7 @@ all_management_operations(Config) ->
202200

203201
{ok, Exchange} = rpc(Config, rabbit_exchange, lookup, [rabbit_misc:r(<<"/">>, exchange, XName)]),
204202
?assertMatch(#exchange{type = fanout,
205-
durable = false,
203+
durable = true,
206204
auto_delete = true,
207205
internal = false,
208206
arguments = [{<<"x-📥"/utf8>>, longstr, <<"📮"/utf8>>}]},
@@ -281,13 +279,12 @@ queue_defaults(Config) ->
281279
queue_properties(Config) ->
282280
Init = {_, LinkPair} = init(Config),
283281
QName = atom_to_binary(?FUNCTION_NAME),
284-
{ok, _} = rabbitmq_amqp_client:declare_queue(LinkPair, QName, #{durable => false,
285-
exclusive => true,
282+
{ok, _} = rabbitmq_amqp_client:declare_queue(LinkPair, QName, #{exclusive => true,
286283
auto_delete => true}),
287284
[Q] = rpc(Config, rabbit_amqqueue, list, []),
288-
?assertNot(rpc(Config, amqqueue, is_durable, [Q])),
289285
?assert(rpc(Config, amqqueue, is_exclusive, [Q])),
290286
?assert(rpc(Config, amqqueue, is_auto_delete, [Q])),
287+
?assert(rpc(Config, amqqueue, is_durable, [Q])),
291288

292289
{ok, _} = rabbitmq_amqp_client:delete_queue(LinkPair, QName),
293290
ok = cleanup(Init).
@@ -310,8 +307,7 @@ exchange_defaults(Config) ->
310307
queue_binding_args(Config) ->
311308
Init = {_, LinkPair = #link_pair{session = Session}} = init(Config),
312309
QName = <<"my queue ~!@#$%^&*()_+🙈`-=[]\;',./"/utf8>>,
313-
Q = #{durable => false,
314-
exclusive => true,
310+
Q = #{exclusive => true,
315311
auto_delete => false,
316312
arguments => #{<<"x-queue-type">> => {utf8, <<"classic">>}}},
317313
{ok, #{}} = rabbitmq_amqp_client:declare_queue(LinkPair, QName, Q),
@@ -589,8 +585,7 @@ declare_exchange_inequivalent_fields(Config) ->
589585
classic_queue_stopped(Config) ->
590586
Init2 = {_, LinkPair2} = init(Config, 2),
591587
QName = <<"👌"/utf8>>,
592-
{ok, #{durable := true,
593-
type := <<"classic">>}} = rabbitmq_amqp_client:declare_queue(LinkPair2, QName, #{}),
588+
{ok, #{type := <<"classic">>}} = rabbitmq_amqp_client:declare_queue(LinkPair2, QName, #{}),
594589
ok = cleanup(Init2),
595590
ok = rabbit_ct_broker_helpers:stop_node(Config, 2),
596591
%% Classic queue is now stopped.

deps/rabbitmq_consistent_hash_exchange/test/rabbit_exchange_type_consistent_hash_SUITE.erl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ amqp_dead_letter(Config) ->
204204

205205
ok = rabbitmq_amqp_client:declare_exchange(
206206
LinkPair, XName, #{type => <<"x-consistent-hash">>,
207-
durable => true,
208207
auto_delete => true,
209208
arguments => #{<<"hash-property">> => {utf8, <<"correlation_id">>}}}),
210209
{ok, #{type := <<"quorum">>}} = rabbitmq_amqp_client:declare_queue(

0 commit comments

Comments
 (0)