diff --git a/deps/rabbit/priv/schema/rabbit.schema b/deps/rabbit/priv/schema/rabbit.schema index f59479402b60..87fe8b47e773 100644 --- a/deps/rabbit/priv/schema/rabbit.schema +++ b/deps/rabbit/priv/schema/rabbit.schema @@ -889,11 +889,6 @@ end}. {mapping, "channel_max", "rabbit.channel_max", [{datatype, integer}]}. -%% Set the max allowed number of channels per node. -%% `infinity` means "no limit". -%% -%% {channel_max_per_node, infinity}, - {mapping, "channel_max_per_node", "rabbit.channel_max_per_node", [{datatype, [{atom, infinity}, integer]}]}. diff --git a/deps/rabbit/src/rabbit_channel.erl b/deps/rabbit/src/rabbit_channel.erl index f25ee6225196..c3d7202d5eec 100644 --- a/deps/rabbit/src/rabbit_channel.erl +++ b/deps/rabbit/src/rabbit_channel.erl @@ -105,8 +105,8 @@ consumer_prefetch, consumer_timeout, authz_context, + max_consumers, % taken from rabbit.consumer_max_per_channel %% defines how ofter gc will be executed - max_consumers % taken from rabbit.consumer_max_per_channel writer_gc_threshold }). @@ -1318,7 +1318,7 @@ handle_method(#'basic.consume'{queue = <<"amq.rabbitmq.reply-to">>, _, State = #ch{reply_consumer = ReplyConsumer, cfg = #conf{max_consumers = MaxConsumers}, consumer_mapping = ConsumerMapping}) -> - CurrentConsumers = length(maps:keys(ConsumerMapping)), + CurrentConsumers = maps:size(ConsumerMapping), case maps:find(CTag0, ConsumerMapping) of error when CurrentConsumers >= MaxConsumers -> % false when MaxConsumers is 'infinity' rabbit_misc:protocol_error( diff --git a/deps/rabbit/test/per_node_limit_SUITE.erl b/deps/rabbit/test/per_node_limit_SUITE.erl index 21af12c09847..962a7f3ede9d 100644 --- a/deps/rabbit/test/per_node_limit_SUITE.erl +++ b/deps/rabbit/test/per_node_limit_SUITE.erl @@ -145,7 +145,7 @@ node_channel_limit(Config) -> ok. channel_consumers_limit(Config) -> - set_node_limit(Config, consumer_max_per_channel, 1), + set_node_limit(Config, consumer_max_per_channel, 2), VHost = <<"foobar">>, User = <<"guest">>, @@ -155,8 +155,9 @@ channel_consumers_limit(Config) -> {ok, Ch} = open_channel(Conn1), Q = <<"Q">>, Tag = <<"Tag">>, - {ok, _} = consume(Ch, Q, Tag), - {error, not_allowed_crash} = consume(Ch, Q, Tag), % Reusing Tag should fail + {ok, _} = consume(Ch, Q, <<"Tag1">>), + {ok, _} = consume(Ch, Q, <<"Tag2">>), + {error, not_allowed_crash} = consume(Ch, Q, <<"Tag3">>), % Third consumer should fail close_all_connections([Conn1]), ok.