Skip to content

Commit 1561e5c

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) (cherry picked from commit f90a4e1)
1 parent dce5ecd commit 1561e5c

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
@@ -778,31 +778,38 @@ augment_declare_args(VHost, Durable, Exclusive, AutoDelete, Args0) ->
778778
#{default_queue_type := DefaultQueueType}
779779
when is_binary(DefaultQueueType) andalso
780780
not HasQTypeArg ->
781-
Type = rabbit_queue_type:discover(DefaultQueueType),
782-
IsPermitted = is_queue_args_combination_permitted(
783-
Durable, Exclusive),
784-
IsCompatible = rabbit_queue_type:is_compatible(
785-
Type, Durable, Exclusive, AutoDelete),
786-
case IsPermitted andalso IsCompatible of
787-
true ->
788-
%% patch up declare arguments with x-queue-type if there
789-
%% is a vhost default set the queue is durable and not exclusive
790-
%% and there is no queue type argument
791-
%% present
792-
rabbit_misc:set_table_value(Args0,
793-
<<"x-queue-type">>,
794-
longstr,
795-
DefaultQueueType);
796-
false ->
797-
%% if the properties are incompatible with the declared
798-
%% DQT, use the fall back type
799-
rabbit_misc:set_table_value(Args0,
800-
<<"x-queue-type">>,
801-
longstr,
802-
rabbit_queue_type:short_alias_of(rabbit_queue_type:fallback()))
803-
end;
781+
update_args_table_with_queue_type(DefaultQueueType, Durable, Exclusive, AutoDelete, Args0);
804782
_ ->
805-
Args0
783+
case HasQTypeArg of
784+
true -> Args0;
785+
false ->
786+
update_args_table_with_queue_type(rabbit_queue_type:short_alias_of(rabbit_queue_type:default()), Durable, Exclusive, AutoDelete, Args0)
787+
end
788+
end.
789+
790+
update_args_table_with_queue_type(DefaultQueueType, Durable, Exclusive, AutoDelete, Args) ->
791+
Type = rabbit_queue_type:discover(DefaultQueueType),
792+
IsPermitted = is_queue_args_combination_permitted(
793+
Durable, Exclusive),
794+
IsCompatible = rabbit_queue_type:is_compatible(
795+
Type, Durable, Exclusive, AutoDelete),
796+
case IsPermitted andalso IsCompatible of
797+
true ->
798+
%% patch up declare arguments with x-queue-type if there
799+
%% is a vhost default set the queue is durable and not exclusive
800+
%% and there is no queue type argument
801+
%% present
802+
rabbit_misc:set_table_value(Args,
803+
<<"x-queue-type">>,
804+
longstr,
805+
DefaultQueueType);
806+
false ->
807+
%% if the properties are incompatible with the declared
808+
%% DQT, use the fall back type
809+
rabbit_misc:set_table_value(Args,
810+
<<"x-queue-type">>,
811+
longstr,
812+
rabbit_queue_type:short_alias_of(rabbit_queue_type:fallback()))
806813
end.
807814

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

0 commit comments

Comments
 (0)