Skip to content

Commit

Permalink
Move the check to be called on all queue types
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonUnge committed May 13, 2024
1 parent 083889e commit 724c60b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 0 additions & 1 deletion deps/rabbit/src/rabbit_channel.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2471,7 +2471,6 @@ handle_method(#'queue.declare'{queue = QueueNameBin,
{ok, QueueName, MessageCount, ConsumerCount};
{error, not_found} ->
%% enforce the limit for newly declared queues only
check_vhost_queue_limit(QueueName, VHostPath),
DlxKey = <<"x-dead-letter-exchange">>,
case rabbit_misc:r_arg(VHostPath, exchange, Args, DlxKey) of
undefined ->
Expand Down
11 changes: 11 additions & 0 deletions deps/rabbit/src/rabbit_queue_type.erl
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ is_compatible(Type, Durable, Exclusive, AutoDelete) ->
declare(Q0, Node) ->
Q = rabbit_queue_decorator:set(rabbit_policy:set(Q0)),
Mod = amqqueue:get_type(Q),
ok = check_vhost_queue_limit(Q),
Mod:declare(Q, Node).

-spec delete(amqqueue:amqqueue(), boolean(),
Expand Down Expand Up @@ -765,3 +766,13 @@ known_queue_type_names() ->
{QueueTypes, _} = lists:unzip(Registered),
QTypeBins = lists:map(fun(X) -> atom_to_binary(X) end, QueueTypes),
?KNOWN_QUEUE_TYPES ++ QTypeBins.

check_vhost_queue_limit(Q) ->
#resource{name = QueueName} = amqqueue:get_name(Q),
VHost = amqqueue:get_vhost(Q),
case rabbit_vhost_limit:is_over_queue_limit(VHost) of
false -> ok;
{true, Limit} -> rabbit_misc:precondition_failed("cannot declare queue '~ts': "
"queue limit in vhost '~ts' (~tp) is reached",
[QueueName, VHost, Limit])
end.

0 comments on commit 724c60b

Please sign in to comment.