Package org.atmosphere.interceptor
Class BackpressureInterceptor
java.lang.Object
org.atmosphere.cpr.AtmosphereInterceptorAdapter
org.atmosphere.interceptor.BackpressureInterceptor
- All Implemented Interfaces:
AtmosphereInterceptor,AtmosphereConfigAware,InvokationOrder
Backpressure interceptor that tracks per-client pending message counts
and applies configurable policies when a client falls behind.
Configuration (init-params or ApplicationConfig)
org.atmosphere.backpressure.highWaterMark— max pending messages per client (default: 1000)org.atmosphere.backpressure.policy— what to do when exceeded:drop-oldest,drop-newest,disconnect(default: drop-oldest)
Usage
framework.interceptor(new BackpressureInterceptor());
- Since:
- 4.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumBackpressure drop policy.Nested classes/interfaces inherited from interface org.atmosphere.interceptor.InvokationOrder
InvokationOrder.PRIORITY -
Field Summary
Fields inherited from interface org.atmosphere.interceptor.InvokationOrder
AFTER_DEFAULT, BEFORE_DEFAULT, FIRST_BEFORE_DEFAULT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanallowMessage(String uuid) Check if a message can be delivered to the given resource.voidconfigure(AtmosphereConfig config) Configure an AtmosphereFramework object.intInvoked before anAtmosphereResourcegets dispatched toAtmosphereHandler.intpendingCount(String uuid) policy()toString()longlongMethods inherited from class org.atmosphere.cpr.AtmosphereInterceptorAdapter
destroy, postInspect, priority
-
Constructor Details
-
BackpressureInterceptor
public BackpressureInterceptor()
-
-
Method Details
-
configure
Description copied from interface:AtmosphereConfigAwareConfigure an AtmosphereFramework object.- Specified by:
configurein interfaceAtmosphereConfigAware- Overrides:
configurein classAtmosphereInterceptorAdapter- Parameters:
config-AtmosphereConfig
-
inspect
Description copied from interface:AtmosphereInterceptorInvoked before anAtmosphereResourcegets dispatched toAtmosphereHandler.- Specified by:
inspectin interfaceAtmosphereInterceptor- Overrides:
inspectin classAtmosphereInterceptorAdapter- Parameters:
r- aAtmosphereResource- Returns:
Action.CONTINUEorAction.SUSPENDto dispatch theAtmosphereResourceto otherAtmosphereInterceptororAtmosphereHandler. ReturnAction.TYPE.CANCELLEDto stop the processing.
-
allowMessage
Check if a message can be delivered to the given resource. Call this before queueing a message for delivery.- Parameters:
uuid- the resource UUID- Returns:
- true if the message should be delivered, false if dropped
-
pendingCount
- Returns:
- the number of pending messages for the given resource
-
totalDrops
public long totalDrops()- Returns:
- total messages dropped due to backpressure
-
totalDisconnects
public long totalDisconnects()- Returns:
- total clients disconnected due to backpressure
-
highWaterMark
public int highWaterMark()- Returns:
- the configured high water mark
-
policy
- Returns:
- the configured policy
-
toString
- Overrides:
toStringin classAtmosphereInterceptorAdapter
-