Class RateLimitingInterceptor

java.lang.Object
org.atmosphere.cpr.AtmosphereInterceptorAdapter
org.atmosphere.interceptor.RateLimitingInterceptor
All Implemented Interfaces:
AtmosphereInterceptor, AtmosphereConfigAware, InvokationOrder

public class RateLimitingInterceptor extends AtmosphereInterceptorAdapter
Inbound rate-limiting interceptor using a token-bucket algorithm. Limits the number of messages a single client can send per time window, preventing abuse and protecting server resources.

The token bucket refills at a steady rate of maxMessages / windowSeconds tokens per second, with bursts up to maxMessages allowed. This provides smooth rate limiting that tolerates short bursts while enforcing long-term limits.

Configuration (init-params or ApplicationConfig)

  • org.atmosphere.rateLimit.maxMessages — max messages per window / burst size (default: 100)
  • org.atmosphere.rateLimit.windowSeconds — refill window in seconds (default: 60)
  • org.atmosphere.rateLimit.policy — action when exceeded: drop (silent), disconnect (close connection) (default: drop)

Usage


 framework.interceptor(new RateLimitingInterceptor());
 
Since:
4.0