@Nullable private ScheduledFuture<?> initLoggingTask(long initialDelay) { if (this.sockJsTaskScheduler != null && this.loggingPeriod > 0 && logger.isInfoEnabled()) { return this.sockJsTaskScheduler.scheduleAtFixedRate(() -> logger.info(WebSocketMessageBrokerStats.this.toString()), initialDelay, this.loggingPeriod, TimeUnit.MILLISECONDS); } return null; }
@Bean public WebSocketMessageBrokerStats webSocketMessageBrokerStats() { AbstractBrokerMessageHandler relayBean = stompBrokerRelayMessageHandler(); // Ensure STOMP endpoints are registered stompWebSocketHandlerMapping(); WebSocketMessageBrokerStats stats = new WebSocketMessageBrokerStats(); stats.setSubProtocolWebSocketHandler((SubProtocolWebSocketHandler) subProtocolWebSocketHandler()); if (relayBean instanceof StompBrokerRelayMessageHandler) { stats.setStompBrokerRelay((StompBrokerRelayMessageHandler) relayBean); } stats.setInboundChannelExecutor(clientInboundChannelExecutor()); stats.setOutboundChannelExecutor(clientOutboundChannelExecutor()); stats.setSockJsTaskScheduler(messageBrokerTaskScheduler()); return stats; }
public String toString() { return "WebSocketSession[" + getWebSocketSessionStatsInfo() + "]" + ", stompSubProtocol[" + getStompSubProtocolStatsInfo() + "]" + ", stompBrokerRelay[" + getStompBrokerRelayStatsInfo() + "]" + ", inboundChannel[" + getClientInboundExecutorStatsInfo() + "]" + ", outboundChannel[" + getClientOutboundExecutorStatsInfo() + "]" + ", sockJsScheduler[" + getSockJsTaskSchedulerStatsInfo() + "]"; }
/** * Get stats about the executor processing incoming messages from WebSocket clients. */ public String getClientInboundExecutorStatsInfo() { return (this.inboundChannelExecutor != null ? getExecutorStatsInfo(this.inboundChannelExecutor) : "null"); }
/** * Set the frequency for logging information at INFO level in milliseconds. * If set 0 or less than 0, the logging task is cancelled. * <p>By default this property is set to 30 minutes (30 * 60 * 1000). */ public void setLoggingPeriod(long period) { if (this.loggingTask != null) { this.loggingTask.cancel(true); } this.loggingPeriod = period; this.loggingTask = initLoggingTask(0); }
/** * Get stats about the SockJS task scheduler. */ public String getSockJsTaskSchedulerStatsInfo() { return (this.sockJsTaskScheduler != null ? getExecutorStatsInfo(this.sockJsTaskScheduler) : "null"); }
public void setSockJsTaskScheduler(ThreadPoolTaskScheduler sockJsTaskScheduler) { this.sockJsTaskScheduler = sockJsTaskScheduler.getScheduledThreadPoolExecutor(); this.loggingTask = initLoggingTask(TimeUnit.MINUTES.toMillis(1)); }
public String toString() { return "WebSocketSession[" + getWebSocketSessionStatsInfo() + "]" + ", stompSubProtocol[" + getStompSubProtocolStatsInfo() + "]" + ", stompBrokerRelay[" + getStompBrokerRelayStatsInfo() + "]" + ", inboundChannel[" + getClientInboundExecutorStatsInfo() + "]" + ", outboundChannel[" + getClientOutboundExecutorStatsInfo() + "]" + ", sockJsScheduler[" + getSockJsTaskSchedulerStatsInfo() + "]"; }
@Bean public WebSocketMessageBrokerStats webSocketMessageBrokerStats() { AbstractBrokerMessageHandler relayBean = stompBrokerRelayMessageHandler(); // Ensure STOMP endpoints are registered stompWebSocketHandlerMapping(); WebSocketMessageBrokerStats stats = new WebSocketMessageBrokerStats(); stats.setSubProtocolWebSocketHandler((SubProtocolWebSocketHandler) subProtocolWebSocketHandler()); if (relayBean instanceof StompBrokerRelayMessageHandler) { stats.setStompBrokerRelay((StompBrokerRelayMessageHandler) relayBean); } stats.setInboundChannelExecutor(clientInboundChannelExecutor()); stats.setOutboundChannelExecutor(clientOutboundChannelExecutor()); stats.setSockJsTaskScheduler(messageBrokerTaskScheduler()); return stats; }
/** * Get stats about the executor processing outgoing messages to WebSocket clients. */ public String getClientOutboundExecutorStatsInfo() { return (this.outboundChannelExecutor != null ? getExecutorStatsInfo(this.outboundChannelExecutor) : "null"); }
@Test public void webSocketMessageBrokerStats() { ApplicationContext config = createConfig(TestChannelConfig.class, TestConfigurer.class); String name = "webSocketMessageBrokerStats"; WebSocketMessageBrokerStats stats = config.getBean(name, WebSocketMessageBrokerStats.class); String actual = stats.toString(); String expected = "WebSocketSession\\[0 current WS\\(0\\)-HttpStream\\(0\\)-HttpPoll\\(0\\), " + "0 total, 0 closed abnormally \\(0 connect failure, 0 send limit, 0 transport error\\)\\], " + "stompSubProtocol\\[processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)\\], " + "stompBrokerRelay\\[null\\], " + "inboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, completed tasks = \\d\\], " + "outboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, completed tasks = \\d\\], " + "sockJsScheduler\\[pool size = \\d, active threads = \\d, queued tasks = \\d, completed tasks = \\d\\]"; assertTrue("\nExpected: " + expected.replace("\\", "") + "\n Actual: " + actual, actual.matches(expected)); }
/** * Set the frequency for logging information at INFO level in milliseconds. * If set 0 or less than 0, the logging task is cancelled. * <p>By default this property is set to 30 minutes (30 * 60 * 1000). */ public void setLoggingPeriod(long period) { if (this.loggingTask != null) { this.loggingTask.cancel(true); } this.loggingPeriod = period; this.loggingTask = initLoggingTask(0); }
public String toString() { return "WebSocketSession[" + getWebSocketSessionStatsInfo() + "]" + ", stompSubProtocol[" + getStompSubProtocolStatsInfo() + "]" + ", stompBrokerRelay[" + getStompBrokerRelayStatsInfo() + "]" + ", inboundChannel[" + getClientInboundExecutorStatsInfo() + "]" + ", outboundChannel[" + getClientOutboundExecutorStatsInfo() + "]" + ", sockJsScheduler[" + getSockJsTaskSchedulerStatsInfo() + "]"; }
@Bean public WebSocketMessageBrokerStats webSocketMessageBrokerStats() { AbstractBrokerMessageHandler relayBean = stompBrokerRelayMessageHandler(); // Ensure STOMP endpoints are registered stompWebSocketHandlerMapping(); WebSocketMessageBrokerStats stats = new WebSocketMessageBrokerStats(); stats.setSubProtocolWebSocketHandler((SubProtocolWebSocketHandler) subProtocolWebSocketHandler()); if (relayBean instanceof StompBrokerRelayMessageHandler) { stats.setStompBrokerRelay((StompBrokerRelayMessageHandler) relayBean); } stats.setInboundChannelExecutor(clientInboundChannelExecutor()); stats.setOutboundChannelExecutor(clientOutboundChannelExecutor()); stats.setSockJsTaskScheduler(messageBrokerTaskScheduler()); return stats; }
/** * Get stats about the executor processing outgoing messages to WebSocket clients. */ public String getClientOutboundExecutorStatsInfo() { return (this.outboundChannelExecutor != null ? getExecutorStatsInfo(this.outboundChannelExecutor) : "null"); }
String actual = stats.toString(); String expected = "WebSocketSession\\[0 current WS\\(0\\)-HttpStream\\(0\\)-HttpPoll\\(0\\), " + "0 total, 0 closed abnormally \\(0 connect failure, 0 send limit, 0 transport error\\)\\], " +
/** * Set the frequency for logging information at INFO level in milliseconds. * If set 0 or less than 0, the logging task is cancelled. * <p>By default this property is set to 30 minutes (30 * 60 * 1000). */ public void setLoggingPeriod(long period) { if (this.loggingTask != null) { this.loggingTask.cancel(true); } this.loggingPeriod = period; this.loggingTask = initLoggingTask(0); }
/** * Get stats about the executor processing incoming messages from WebSocket clients. */ public String getClientInboundExecutorStatsInfo() { return (this.inboundChannelExecutor != null ? getExecutorStatsInfo(this.inboundChannelExecutor) : "null"); }
@Nullable private ScheduledFuture<?> initLoggingTask(long initialDelay) { if (this.sockJsTaskScheduler != null && this.loggingPeriod > 0 && logger.isInfoEnabled()) { return this.sockJsTaskScheduler.scheduleAtFixedRate(() -> logger.info(WebSocketMessageBrokerStats.this.toString()), initialDelay, this.loggingPeriod, TimeUnit.MILLISECONDS); } return null; }
public void setSockJsTaskScheduler(ThreadPoolTaskScheduler sockJsTaskScheduler) { this.sockJsTaskScheduler = sockJsTaskScheduler.getScheduledThreadPoolExecutor(); this.loggingTask = initLoggingTask(TimeUnit.MINUTES.toMillis(1)); }