public class RequestLimit extends Object
This is basically a counter with a configured set of limits, that is used by RequestLimitingHandler
.
When the number of active requests goes over the configured max requests then requests will be suspended and queued.
If the queue is full requests will be rejected with a 503 Service Unavailable according to RFC7231 Section 6.6.4.
The reason why this is abstracted out into a separate class is so that multiple handlers can share the same state. This allows for fine grained control of resources.
RequestLimitingHandler
Constructor and Description |
---|
RequestLimit(int maximumConcurrentRequests) |
RequestLimit(int maximumConcurrentRequests, int queueSize) Construct a new instance. |
Modifier and Type | Method and Description |
---|---|
HttpHandler | getFailureHandler() |
int | getMaximumConcurrentRequests() Get the maximum concurrent requests. |
void | handleRequest(HttpServerExchange exchange, HttpHandler next) |
void | setFailureHandler(HttpHandler failureHandler) |
int | setMaximumConcurrentRequests(int newMax) Set the maximum concurrent requests. |
public RequestLimit(int maximumConcurrentRequests)
public RequestLimit(int maximumConcurrentRequests, int queueSize)
maximumConcurrentRequests
- the maximum concurrent requestsqueueSize
- The maximum number of requests to queuepublic void handleRequest(HttpServerExchange exchange, HttpHandler next) throws Exception
Exception
public int getMaximumConcurrentRequests()
public int setMaximumConcurrentRequests(int newMax)
newMax
- the maximum concurrent requestspublic HttpHandler getFailureHandler()
public void setFailureHandler(HttpHandler failureHandler)
Copyright © 2020 JBoss by Red Hat. All rights reserved.