@@ -7,7 +7,7 @@ Copyright (c) 2005-2025 Broadcom. All Rights Reserved. The term "Broadcom" refer
77
88All rights reserved. This program and the accompanying materials
99are made available under the terms of the under the Apache License,
10- Version 2.0 (the "License” ); you may not use this file except in compliance
10+ Version 2.0 (the "License" ); you may not use this file except in compliance
1111with the License. You may obtain a copy of the License at
1212
1313https://www.apache.org/licenses/LICENSE-2.0
@@ -19,6 +19,9 @@ See the License for the specific language governing permissions and
1919limitations under the License.
2020-->
2121
22+ import Tabs from '@theme/Tabs ';
23+ import TabItem from '@theme/TabItem ';
24+
2225# Per-user Resource Limits
2326
2427## Overview
@@ -30,24 +33,40 @@ These limits can be used as guard rails in environments where applications
3033cannot be trusted and monitored in detail, for example, when RabbitMQ clusters
3134are offered as a service.
3235
33- The limits can be configured using [ ` rabbitmqctl set_user_limits ` ] ( ./cli ) or the [ HTTP API] ( ./management#http-api ) .
36+ The limits can be configured using CLI tools or the [ HTTP API] ( ./management#http-api ) .
3437
3538## Maximum Number of Connections {#connections}
3639
3740To limit how many connection a user can open, set the ` max-connections ` limit to
3841a positive integer:
3942
43+ <Tabs groupId =" examples " >
44+ <TabItem value =" bash " label =" rabbitmqctl with bash " default >
4045``` bash
4146rabbitmqctl set_user_limits user1 ' {"max-connections": 10}'
4247```
48+ </TabItem >
4349
44- To set the limit over the HTTP API, use the following endpoint:
50+ <TabItem value =" rabbitmqadmin " label =" rabbitmqadmin with bash " >
51+ ``` bash
52+ rabbitmqadmin user_limits declare --user user1 --name max-connections --value 10
53+ ```
54+ </TabItem >
55+
56+ <TabItem value =" PowerShell " label =" rabbitmqctl with PowerShell " >
57+ ``` PowerShell
58+ rabbitmqctl.bat set_user_limits user1 "{""max-connections"": 10}"
59+ ```
60+ </TabItem >
4561
46- ``` ini
47- PUT /api/user-limits/{username}/{limit}
62+ <TabItem value =" rabbitmqadmin-PowerShell " label =" rabbitmqadmin with PowerShell " >
63+ ``` PowerShell
64+ rabbitmqadmin.exe user_limits declare --user user1 --name max-connections --value 10
4865```
66+ </TabItem >
4967
50- and a request body like this:
68+ <TabItem value =" HTTP API " label =" HTTP API " >
69+ Use the ` PUT /api/user-limits/{username}/{limit} ` endpoint with a request body like this:
5170
5271``` javascript
5372{" value" : 20 }
@@ -56,7 +75,6 @@ and a request body like this:
5675Here is an example that uses ` curl ` :
5776
5877``` bash
59- # using the HTTP API
6078curl -v -u guest:guest -X PUT http://localhost:15672/api/user-limits/user1/max-connections \
6179 -H " content-type: application/json" \
6280 -d @- << EOF
@@ -65,24 +83,41 @@ curl -v -u guest:guest -X PUT http://localhost:15672/api/user-limits/user1/max-c
6583}
6684EOF
6785```
86+ </TabItem >
87+ </Tabs >
6888
6989## Maximum Number of Channels {#channels}
7090
7191To limit how many channels, in total, a user can open, set the ` max-channels ` limit to
7292a positive integer:
7393
94+ <Tabs groupId =" examples " >
95+ <TabItem value =" bash " label =" rabbitmqctl with bash " default >
7496``` bash
75- # using CLI tools
7697rabbitmqctl set_user_limits guest ' {"max-connections": 10, "max-channels": 20}'
7798```
99+ </TabItem >
78100
79- To set the limit over the HTTP API, use the following endpoint:
101+ <TabItem value =" rabbitmqadmin " label =" rabbitmqadmin with bash " >
102+ ``` bash
103+ rabbitmqadmin user_limits declare --user guest --name max-channels --value 20
104+ ```
105+ </TabItem >
80106
81- ``` ini
82- PUT /api/user-limits/{username}/{limit}
107+ <TabItem value =" PowerShell " label =" rabbitmqctl with PowerShell " >
108+ ``` PowerShell
109+ rabbitmqctl.bat set_user_limits guest "{""max-connections"": 10, ""max-channels"": 20}"
83110```
111+ </TabItem >
84112
85- and a request body like this:
113+ <TabItem value =" rabbitmqadmin-PowerShell " label =" rabbitmqadmin with PowerShell " >
114+ ``` PowerShell
115+ rabbitmqadmin.exe user_limits declare --user guest --name max-channels --value 20
116+ ```
117+ </TabItem >
118+
119+ <TabItem value =" HTTP API " label =" HTTP API " >
120+ Use the ` PUT /api/user-limits/{username}/{limit} ` endpoint with a request body like this:
86121
87122``` javascript
88123{" value" : 20 }
@@ -91,7 +126,6 @@ and a request body like this:
91126Here is an example that uses ` curl ` to set a limit for user ` user1 ` :
92127
93128``` bash
94- # using the HTTP API
95129curl -v -u guest:guest -X PUT http://localhost:15672/api/user-limits/user1/max-channels \
96130 -H " content-type: application/json" \
97131 -d @- << EOF
@@ -100,17 +134,55 @@ curl -v -u guest:guest -X PUT http://localhost:15672/api/user-limits/user1/max-c
100134}
101135EOF
102136```
137+ </TabItem >
138+ </Tabs >
103139
104140The limit is applied to the total number of channels across all connections opened
105141by the user. Therefore, it must be equal or greater than that the aforementioned maximum
106142connection limit.
107143
108- ## Clearing User Limits {#clearing}
144+ ## Listing User Limits {#listing}
145+
146+ To list limits for a specific user:
147+
148+ <Tabs groupId =" examples " >
149+ <TabItem value =" bash " label =" rabbitmqctl with bash " default >
150+ ``` bash
151+ rabbitmqctl list_user_limits user1
152+ ```
153+ </TabItem >
154+
155+ <TabItem value =" rabbitmqadmin " label =" rabbitmqadmin with bash " >
156+ ``` bash
157+ rabbitmqadmin user_limits list --user user1
158+ ```
159+ </TabItem >
160+
161+ <TabItem value =" PowerShell " label =" rabbitmqctl with PowerShell " >
162+ ``` PowerShell
163+ rabbitmqctl.bat list_user_limits user1
164+ ```
165+ </TabItem >
166+
167+ <TabItem value =" rabbitmqadmin-PowerShell " label =" rabbitmqadmin with PowerShell " >
168+ ``` PowerShell
169+ rabbitmqadmin.exe user_limits list --user user1
170+ ```
171+ </TabItem >
109172
110- To clear all limits for a user, use [ ` rabbitmqctl clear_user_limits ` ] ( ./cli ) or the [ HTTP API] ( ./management#http-api ) .
173+ <TabItem value =" HTTP API " label =" HTTP API " >
174+ ``` bash
175+ curl -u guest:guest -X GET http://localhost:15672/api/user-limits/user1
176+ ```
177+ </TabItem >
178+ </Tabs >
179+
180+ ## Clearing User Limits {#clearing}
111181
112- Here are some examples that clear all limits for user ` user1 ` :
182+ To clear limits for a user, use CLI tools or the [ HTTP API ] ( ./management#http-api ) .
113183
184+ <Tabs groupId =" examples " >
185+ <TabItem value =" bash " label =" rabbitmqctl with bash " default >
114186``` bash
115187# clears the maximum number of connections limit
116188rabbitmqctl clear_user_limits user1 ' max-connections'
@@ -121,20 +193,50 @@ rabbitmqctl clear_user_limits user1 'max-channels'
121193# clears all limits in a single operation
122194rabbitmqctl clear_user_limits user1 all
123195```
196+ </TabItem >
197+
198+ <TabItem value =" rabbitmqadmin " label =" rabbitmqadmin with bash " >
199+ ``` bash
200+ # clears the maximum number of connections limit
201+ rabbitmqadmin user_limits delete --user user1 --name max-connections
202+
203+ # clears the maximum number of channels limit
204+ rabbitmqadmin user_limits delete --user user1 --name max-channels
205+ ```
206+ </TabItem >
207+
208+ <TabItem value =" PowerShell " label =" rabbitmqctl with PowerShell " >
209+ ``` PowerShell
210+ # clears the maximum number of connections limit
211+ rabbitmqctl.bat clear_user_limits user1 "max-connections"
212+
213+ # clears the maximum number of channels limit
214+ rabbitmqctl.bat clear_user_limits user1 "max-channels"
215+
216+ # clears all limits in a single operation
217+ rabbitmqctl.bat clear_user_limits user1 all
218+ ```
219+ </TabItem >
124220
125- To clear the limit over the HTTP API, use the following endpoint:
221+ <TabItem value =" rabbitmqadmin-PowerShell " label =" rabbitmqadmin with PowerShell " >
222+ ``` PowerShell
223+ # clears the maximum number of connections limit
224+ rabbitmqadmin.exe user_limits delete --user user1 --name max-connections
126225
127- ``` ini
128- DELETE /api/ user-limits/{username}/{limit}
226+ # clears the maximum number of channels limit
227+ rabbitmqadmin.exe user_limits delete -- user user1 --name max-channels
129228```
229+ </TabItem >
130230
131- without a request body.
231+ <TabItem value =" HTTP API " label =" HTTP API " >
232+ Use the ` DELETE /api/user-limits/{username}/{limit} ` endpoint without a request body.
132233
133234Here is an example that uses ` curl ` to clear all limits of user ` user1 ` :
134235
135236``` bash
136- # using the HTTP API
137237curl -v -u guest:guest -X DELETE http://localhost:15672/api/user-limits/user1/max-channels
138238
139239curl -v -u guest:guest -X DELETE http://localhost:15672/api/user-limits/user1/max-connections
140240```
241+ </TabItem >
242+ </Tabs >
0 commit comments