Search in sources :

Example 1 with WebSocketMessageBrokerStats

use of org.springframework.web.socket.config.WebSocketMessageBrokerStats in project spring-framework by spring-projects.

the class WebSocketMessageBrokerConfigurationSupport method webSocketMessageBrokerStats.

@Bean
public WebSocketMessageBrokerStats webSocketMessageBrokerStats() {
    AbstractBrokerMessageHandler relayBean = stompBrokerRelayMessageHandler();
    StompBrokerRelayMessageHandler brokerRelay = (relayBean instanceof StompBrokerRelayMessageHandler ? (StompBrokerRelayMessageHandler) relayBean : null);
    // Ensure STOMP endpoints are registered
    stompWebSocketHandlerMapping();
    WebSocketMessageBrokerStats stats = new WebSocketMessageBrokerStats();
    stats.setSubProtocolWebSocketHandler((SubProtocolWebSocketHandler) subProtocolWebSocketHandler());
    stats.setStompBrokerRelay(brokerRelay);
    stats.setInboundChannelExecutor(clientInboundChannelExecutor());
    stats.setOutboundChannelExecutor(clientOutboundChannelExecutor());
    stats.setSockJsTaskScheduler(messageBrokerTaskScheduler());
    return stats;
}
Also used : StompBrokerRelayMessageHandler(org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler) WebSocketMessageBrokerStats(org.springframework.web.socket.config.WebSocketMessageBrokerStats) AbstractBrokerMessageHandler(org.springframework.messaging.simp.broker.AbstractBrokerMessageHandler) Bean(org.springframework.context.annotation.Bean)

Example 2 with WebSocketMessageBrokerStats

use of org.springframework.web.socket.config.WebSocketMessageBrokerStats in project spring-framework by spring-projects.

the class WebSocketMessageBrokerConfigurationSupportTests method webSocketMessageBrokerStats.

@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\\], " + "outboundChannelpool 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));
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) WebSocketMessageBrokerStats(org.springframework.web.socket.config.WebSocketMessageBrokerStats) Test(org.junit.Test)

Aggregations

WebSocketMessageBrokerStats (org.springframework.web.socket.config.WebSocketMessageBrokerStats)2 Test (org.junit.Test)1 ApplicationContext (org.springframework.context.ApplicationContext)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 Bean (org.springframework.context.annotation.Bean)1 AbstractBrokerMessageHandler (org.springframework.messaging.simp.broker.AbstractBrokerMessageHandler)1 StompBrokerRelayMessageHandler (org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler)1