Skip to content

Commit 55a9f65

Browse files
committed
Mark transient non-exclusive queues as deprecated
[Why] Transient queues are queues that are removed upon node restart. An application developer can't rely on such an arbitrary event to reason about a queue's lifetime. The only exception are exclusive transient queues which have a lifetime linked to that of a client connection. [How] Non-exclusive transient queues are marked as deprecated in the code using the Deprecated features subsystem (based on feature flags). See pull request #7390 for a description of that subsystem. To test RabbitMQ behavior as if the feature was removed, the following configuration setting can be used: deprecated_features.permit.transient_nonexcl_queues = false Non-exclusive transient queues can be turned off anytime, there are no conditions to do that. Once non-exclusive transient queues are turned off, declaring a new queue with those arguments will be rejected with a protocol error. Note that given the marketing calendar, the deprecated feature will go directly from "permitted by default" to "removed" in RabbitMQ 4.0. It won't go through the gradual deprecation process.
1 parent c90d71b commit 55a9f65

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

deps/rabbit/src/rabbit_amqqueue.erl

+32-3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@
107107

108108
%%----------------------------------------------------------------------------
109109

110+
-rabbit_deprecated_feature(
111+
{transient_nonexcl_queues,
112+
#{deprecation_phase => permitted_by_default,
113+
doc_url => "https://blog.rabbitmq.com/posts/2021/08/4.0-deprecation-announcements/#removal-of-transient-non-exclusive-queues"
114+
}}).
115+
110116
-define(CONSUMER_INFO_KEYS,
111117
[queue_name, channel_pid, consumer_tag, ack_required, prefetch_count,
112118
active, activity_status, arguments]).
@@ -223,7 +229,14 @@ declare(QueueName = #resource{virtual_host = VHost}, Durable, AutoDelete, Args,
223229
VHost,
224230
#{user => ActingUser},
225231
Type),
226-
rabbit_queue_type:declare(Q, Node);
232+
case is_queue_args_combination_permitted(Q) of
233+
true ->
234+
rabbit_queue_type:declare(Q, Node);
235+
false ->
236+
Warning = rabbit_deprecated_features:get_warning(
237+
transient_nonexcl_queues),
238+
{protocol_error, internal_error, "~ts", [Warning]}
239+
end;
227240
false ->
228241
{protocol_error, internal_error,
229242
"Cannot declare a queue '~ts' of type '~ts' on node '~ts': "
@@ -721,8 +734,11 @@ augment_declare_args(VHost, Durable, Exclusive, AutoDelete, Args0) ->
721734
when is_binary(DefaultQueueType) andalso
722735
not HasQTypeArg ->
723736
Type = rabbit_queue_type:discover(DefaultQueueType),
724-
case rabbit_queue_type:is_compatible(Type, Durable,
725-
Exclusive, AutoDelete) of
737+
IsPermitted = is_queue_args_combination_permitted(
738+
Durable, Exclusive),
739+
IsCompatible = rabbit_queue_type:is_compatible(
740+
Type, Durable, Exclusive, AutoDelete),
741+
case IsPermitted andalso IsCompatible of
726742
true ->
727743
%% patch up declare arguments with x-queue-type if there
728744
%% is a vhost default set the queue is druable and not exclusive
@@ -2074,3 +2090,16 @@ get_bcc_queue(Q, BCCName) ->
20742090
#resource{virtual_host = VHost} = amqqueue:get_name(Q),
20752091
BCCQueueName = rabbit_misc:r(VHost, queue, BCCName),
20762092
rabbit_amqqueue:lookup(BCCQueueName).
2093+
2094+
is_queue_args_combination_permitted(Q) ->
2095+
Durable = amqqueue:is_durable(Q),
2096+
Exclusive = is_exclusive(Q),
2097+
is_queue_args_combination_permitted(Durable, Exclusive).
2098+
2099+
is_queue_args_combination_permitted(Durable, Exclusive) ->
2100+
case not Durable andalso not Exclusive of
2101+
false ->
2102+
true;
2103+
true ->
2104+
rabbit_deprecated_features:is_permitted(transient_nonexcl_queues)
2105+
end.

0 commit comments

Comments
 (0)