Skip to content

Commit f011a8e

Browse files
committed
Move code to declare to be called by all queue types.
1 parent e2b0e9b commit f011a8e

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

deps/rabbit/src/rabbit_channel.erl

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,21 +1065,6 @@ check_vhost_queue_limit(#resource{name = QueueName}, VHost) ->
10651065

10661066
end.
10671067

1068-
check_cluster_queue_limit(#resource{name = QueueName}) ->
1069-
case rabbit_misc:get_env(rabbit, cluster_queue_limit, infinity) of
1070-
infinity ->
1071-
false;
1072-
Limit ->
1073-
case rabbit_db_queue:count() >= Limit of
1074-
true ->
1075-
rabbit_misc:precondition_failed("cannot declare queue '~ts': "
1076-
"queue limit in cluster (~tp) is reached",
1077-
[QueueName, Limit]);
1078-
false ->
1079-
ok
1080-
end
1081-
end.
1082-
10831068
qbin_to_resource(QueueNameBin, VHostPath) ->
10841069
name_to_resource(queue, QueueNameBin, VHostPath).
10851070

@@ -2541,7 +2526,6 @@ handle_method(#'queue.declare'{queue = QueueNameBin,
25412526
{error, not_found} ->
25422527
%% enforce the limit for newly declared queues only
25432528
check_vhost_queue_limit(QueueName, VHostPath),
2544-
check_cluster_queue_limit(QueueName),
25452529
DlxKey = <<"x-dead-letter-exchange">>,
25462530
case rabbit_misc:r_arg(VHostPath, exchange, Args, DlxKey) of
25472531
undefined ->

deps/rabbit/src/rabbit_queue_type.erl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ is_compatible(Type, Durable, Exclusive, AutoDelete) ->
281281
{'error', Err :: term() }.
282282
declare(Q0, Node) ->
283283
Q = rabbit_queue_decorator:set(rabbit_policy:set(Q0)),
284+
ok = check_cluster_queue_limit(Q),
284285
Mod = amqqueue:get_type(Q),
285286
Mod:declare(Q, Node).
286287

@@ -730,3 +731,19 @@ known_queue_type_names() ->
730731
{QueueTypes, _} = lists:unzip(Registered),
731732
QTypeBins = lists:map(fun(X) -> atom_to_binary(X) end, QueueTypes),
732733
?KNOWN_QUEUE_TYPES ++ QTypeBins.
734+
735+
check_cluster_queue_limit(Q) ->
736+
#resource{name = QueueName} = amqqueue:get_name(Q),
737+
case rabbit_misc:get_env(rabbit, cluster_queue_limit, infinity) of
738+
infinity ->
739+
false;
740+
Limit ->
741+
case rabbit_db_queue:count() >= Limit of
742+
true ->
743+
rabbit_misc:precondition_failed("cannot declare queue '~ts': "
744+
"queue limit in cluster (~tp) is reached",
745+
[QueueName, Limit]);
746+
false ->
747+
ok
748+
end
749+
end.

0 commit comments

Comments
 (0)