Top Description Fields Constructors Methods
org.springframework.web.socket.config

public Class WebSocketMessageBrokerStats

extends Object
implements SmartInitializingSingleton
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.SmartInitializingSingleton
Imports
java.time.Duration, .Instant, java.util.concurrent.Executor, .ScheduledFuture, .ThreadPoolExecutor, .TimeUnit, org.apache.commons.logging.Log, .LogFactory, org.springframework.beans.factory.SmartInitializingSingleton, org.springframework.core.task.TaskExecutor, org.springframework.lang.Nullable, org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler, org.springframework.scheduling.TaskScheduler, org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor, .ThreadPoolTaskScheduler, org.springframework.web.socket.messaging.StompSubProtocolHandler, .SubProtocolHandler, .SubProtocolWebSocketHandler

A central class for aggregating information about internal state and counters from key infrastructure components of the setup that comes with @EnableWebSocketMessageBroker for Java config and <websocket:message-broker> for XML.

By default aggregated information is logged every 30 minutes at INFO level. The frequency of logging can be changed via setLoggingPeriod(long).

This class is declared as a Spring bean by the above configuration with the name "webSocketMessageBrokerStats" and can be easily exported to JMX, e.g. with the MBeanExporter.

Authors
Rossen Stoyanchev, Sam Brannen
Since
4.1

Field Summary

Modifier and TypeField and Description
private TaskExecutor
private static final Log
private long
private ScheduledFuture<?>
private TaskExecutor
private TaskScheduler
private StompBrokerRelayMessageHandler
private StompSubProtocolHandler
private SubProtocolWebSocketHandler

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
afterSingletonsInstantiated()

Implements org.springframework.beans.factory.SmartInitializingSingleton.afterSingletonsInstantiated.

Invoked right at the end of the singleton pre-instantiation phase, with a guarantee that all regular singleton beans have been created already.

public String
getClientInboundExecutorStatsInfo()

Get stats about the executor processing incoming messages from WebSocket clients.

public String
getClientOutboundExecutorStatsInfo()

Get stats about the executor processing outgoing messages to WebSocket clients.

private String
public long
getLoggingPeriod()

Return the configured logging period frequency in milliseconds.

public String
getSockJsTaskSchedulerStatsInfo()

Get stats about the SockJS task scheduler.

public String
getStompBrokerRelayStatsInfo()

Get stats about STOMP broker relay (when using a full-featured STOMP broker).

public String
getStompSubProtocolStatsInfo()

Get stats about STOMP-related WebSocket message processing.

public String
getWebSocketSessionStatsInfo()

Get stats about WebSocket sessions.

private ScheduledFuture<?>
initLoggingTask(long initialDelay)

private StompSubProtocolHandler
public void
setInboundChannelExecutor(TaskExecutor inboundChannelExecutor)

public void
setLoggingPeriod(long period)

Set the frequency for logging information at INFO level in milliseconds.

public void
setOutboundChannelExecutor(TaskExecutor outboundChannelExecutor)

public void
public void
public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

inboundChannelExecutorback to summary
private TaskExecutor inboundChannelExecutor
Annotations
@Nullable
loggerback to summary
private static final Log logger
loggingPeriodback to summary
private long loggingPeriod
loggingTaskback to summary
private ScheduledFuture<?> loggingTask
Annotations
@Nullable
outboundChannelExecutorback to summary
private TaskExecutor outboundChannelExecutor
Annotations
@Nullable
sockJsTaskSchedulerback to summary
private TaskScheduler sockJsTaskScheduler
Annotations
@Nullable
stompBrokerRelayback to summary
private StompBrokerRelayMessageHandler stompBrokerRelay
Annotations
@Nullable
stompSubProtocolHandlerback to summary
private StompSubProtocolHandler stompSubProtocolHandler
Annotations
@Nullable
webSocketHandlerback to summary
private SubProtocolWebSocketHandler webSocketHandler
Annotations
@Nullable

Constructor Detail

WebSocketMessageBrokerStatsback to summary
public WebSocketMessageBrokerStats()

Method Detail

afterSingletonsInstantiatedback to summary
public void afterSingletonsInstantiated()

Implements org.springframework.beans.factory.SmartInitializingSingleton.afterSingletonsInstantiated.

Doc from org.springframework.beans.factory.SmartInitializingSingleton.afterSingletonsInstantiated.

Invoked right at the end of the singleton pre-instantiation phase, with a guarantee that all regular singleton beans have been created already. ListableBeanFactory#getBeansOfType calls within this method won't trigger accidental side effects during bootstrap.

Note

This callback won't be triggered for singleton beans lazily initialized on demand after BeanFactory bootstrap, and not for any other bean scope either. Carefully use it for beans with the intended bootstrap semantics only.

Annotations
@Override
getClientInboundExecutorStatsInfoback to summary
public String getClientInboundExecutorStatsInfo()

Get stats about the executor processing incoming messages from WebSocket clients.

getClientOutboundExecutorStatsInfoback to summary
public String getClientOutboundExecutorStatsInfo()

Get stats about the executor processing outgoing messages to WebSocket clients.

getExecutorStatsInfoback to summary
private String getExecutorStatsInfo(Executor executor)
getLoggingPeriodback to summary
public long getLoggingPeriod()

Return the configured logging period frequency in milliseconds.

getSockJsTaskSchedulerStatsInfoback to summary
public String getSockJsTaskSchedulerStatsInfo()

Get stats about the SockJS task scheduler.

getStompBrokerRelayStatsInfoback to summary
public String getStompBrokerRelayStatsInfo()

Get stats about STOMP broker relay (when using a full-featured STOMP broker).

getStompSubProtocolStatsInfoback to summary
public String getStompSubProtocolStatsInfo()

Get stats about STOMP-related WebSocket message processing.

getWebSocketSessionStatsInfoback to summary
public String getWebSocketSessionStatsInfo()

Get stats about WebSocket sessions.

initLoggingTaskback to summary
private ScheduledFuture<?> initLoggingTask(long initialDelay)
Annotations
@Nullable
initStompSubProtocolHandlerback to summary
private StompSubProtocolHandler initStompSubProtocolHandler()
Annotations
@Nullable
setInboundChannelExecutorback to summary
public void setInboundChannelExecutor(TaskExecutor inboundChannelExecutor)
setLoggingPeriodback to summary
public void setLoggingPeriod(long period)

Set the frequency for logging information at INFO level in milliseconds. If set 0 or less than 0, the logging task is cancelled.

By default this property is set to 30 minutes (30 * 60 * 1000).

setOutboundChannelExecutorback to summary
public void setOutboundChannelExecutor(TaskExecutor outboundChannelExecutor)
setSockJsTaskSchedulerback to summary
public void setSockJsTaskScheduler(TaskScheduler sockJsTaskScheduler)
setStompBrokerRelayback to summary
public void setStompBrokerRelay(StompBrokerRelayMessageHandler stompBrokerRelay)
setSubProtocolWebSocketHandlerback to summary
public void setSubProtocolWebSocketHandler(SubProtocolWebSocketHandler webSocketHandler)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override