Skip to content

Commit f90a4e1

Browse files
michaelklishinmergify[bot]
authored andcommitted
DQT: fall back to node-wide default
when virtual host does not have any metadata. References #11541 #11457 #11528 (cherry picked from commit 29051a8)
1 parent e60d512 commit f90a4e1

File tree

1 file changed

+31
-24
lines changed

1 file changed

+31
-24
lines changed

deps/rabbit/src/rabbit_amqqueue.erl

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -733,31 +733,38 @@ augment_declare_args(VHost, Durable, Exclusive, AutoDelete, Args0) ->
733733
#{default_queue_type := DefaultQueueType}
734734
when is_binary(DefaultQueueType) andalso
735735
not HasQTypeArg ->
736-
Type = rabbit_queue_type:discover(DefaultQueueType),
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
742-
true ->
743-
%% patch up declare arguments with x-queue-type if there
744-
%% is a vhost default set the queue is durable and not exclusive
745-
%% and there is no queue type argument
746-
%% present
747-
rabbit_misc:set_table_value(Args0,
748-
<<"x-queue-type">>,
749-
longstr,
750-
DefaultQueueType);
751-
false ->
752-
%% if the properties are incompatible with the declared
753-
%% DQT, use the fall back type
754-
rabbit_misc:set_table_value(Args0,
755-
<<"x-queue-type">>,
756-
longstr,
757-
rabbit_queue_type:short_alias_of(rabbit_queue_type:fallback()))
758-
end;
736+
update_args_table_with_queue_type(DefaultQueueType, Durable, Exclusive, AutoDelete, Args0);
759737
_ ->
760-
Args0
738+
case HasQTypeArg of
739+
true -> Args0;
740+
false ->
741+
update_args_table_with_queue_type(rabbit_queue_type:short_alias_of(rabbit_queue_type:default()), Durable, Exclusive, AutoDelete, Args0)
742+
end
743+
end.
744+
745+
update_args_table_with_queue_type(DefaultQueueType, Durable, Exclusive, AutoDelete, Args) ->
746+
Type = rabbit_queue_type:discover(DefaultQueueType),
747+
IsPermitted = is_queue_args_combination_permitted(
748+
Durable, Exclusive),
749+
IsCompatible = rabbit_queue_type:is_compatible(
750+
Type, Durable, Exclusive, AutoDelete),
751+
case IsPermitted andalso IsCompatible of
752+
true ->
753+
%% patch up declare arguments with x-queue-type if there
754+
%% is a vhost default set the queue is durable and not exclusive
755+
%% and there is no queue type argument
756+
%% present
757+
rabbit_misc:set_table_value(Args,
758+
<<"x-queue-type">>,
759+
longstr,
760+
DefaultQueueType);
761+
false ->
762+
%% if the properties are incompatible with the declared
763+
%% DQT, use the fall back type
764+
rabbit_misc:set_table_value(Args,
765+
<<"x-queue-type">>,
766+
longstr,
767+
rabbit_queue_type:short_alias_of(rabbit_queue_type:fallback()))
761768
end.
762769

763770
-spec check_exclusive_access(amqqueue:amqqueue(), pid()) ->

0 commit comments

Comments
 (0)