Search in sources :

Example 1 with AbstractBrokerMessageHandler

use of org.springframework.messaging.simp.broker.AbstractBrokerMessageHandler in project spring-framework by spring-projects.

the class AbstractMessageBrokerConfiguration method stompBrokerRelayMessageHandler.

@Bean
public AbstractBrokerMessageHandler stompBrokerRelayMessageHandler() {
    StompBrokerRelayMessageHandler handler = getBrokerRegistry().getStompBrokerRelay(brokerChannel());
    if (handler == null) {
        return new NoOpBrokerMessageHandler();
    }
    Map<String, MessageHandler> subscriptions = new HashMap<>(1);
    String destination = getBrokerRegistry().getUserDestinationBroadcast();
    if (destination != null) {
        subscriptions.put(destination, userDestinationMessageHandler());
    }
    destination = getBrokerRegistry().getUserRegistryBroadcast();
    if (destination != null) {
        subscriptions.put(destination, userRegistryMessageHandler());
    }
    handler.setSystemSubscriptions(subscriptions);
    return handler;
}
Also used : SimpleBrokerMessageHandler(org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler) StompBrokerRelayMessageHandler(org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler) AbstractBrokerMessageHandler(org.springframework.messaging.simp.broker.AbstractBrokerMessageHandler) UserRegistryMessageHandler(org.springframework.messaging.simp.user.UserRegistryMessageHandler) UserDestinationMessageHandler(org.springframework.messaging.simp.user.UserDestinationMessageHandler) MessageHandler(org.springframework.messaging.MessageHandler) SimpAnnotationMethodMessageHandler(org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler) HashMap(java.util.HashMap) StompBrokerRelayMessageHandler(org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler) Bean(org.springframework.context.annotation.Bean)

Example 2 with AbstractBrokerMessageHandler

use of org.springframework.messaging.simp.broker.AbstractBrokerMessageHandler 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)

Aggregations

Bean (org.springframework.context.annotation.Bean)2 AbstractBrokerMessageHandler (org.springframework.messaging.simp.broker.AbstractBrokerMessageHandler)2 StompBrokerRelayMessageHandler (org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler)2 HashMap (java.util.HashMap)1 MessageHandler (org.springframework.messaging.MessageHandler)1 SimpAnnotationMethodMessageHandler (org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler)1 SimpleBrokerMessageHandler (org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler)1 UserDestinationMessageHandler (org.springframework.messaging.simp.user.UserDestinationMessageHandler)1 UserRegistryMessageHandler (org.springframework.messaging.simp.user.UserRegistryMessageHandler)1 WebSocketMessageBrokerStats (org.springframework.web.socket.config.WebSocketMessageBrokerStats)1