Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Valiushko committed Mar 15, 2024
1 parent fcc5500 commit 67a1685
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
5 changes: 0 additions & 5 deletions deps/rabbit/priv/schema/rabbit.schema
Expand Up @@ -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]}]}.

Expand Down
4 changes: 2 additions & 2 deletions deps/rabbit/src/rabbit_channel.erl
Expand Up @@ -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
}).

Expand Down Expand Up @@ -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(
Expand Down
7 changes: 4 additions & 3 deletions deps/rabbit/test/per_node_limit_SUITE.erl
Expand Up @@ -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">>,
Expand All @@ -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.
Expand Down

0 comments on commit 67a1685

Please sign in to comment.