title: Websocket Stomp - Broadcast(Topic,queue)
body: <p>How do I broadcast to all <code>subscribers(Topic)</code> and the specified <code>user(Channel)</code>.</p>
  
  <pre><code>this.messagingTemplate.convertAndSend(destination, message);
  this.messagingTemplate.convertAndSendToUser(userId, destination, message);
  </code></pre>
  
  <p>Is that correct?</p>
  
  <p>What is <code>WebSocketConnectHandlerDecoratorFactory</code> class for?</p>
  
  <pre><code>public final class WebSocketConnectHandlerDecoratorFactory implements WebSocketHandlerDecoratorFactory {
  
      private static final Log logger = LogFactory.getLog(WebSocketConnectHandlerDecoratorFactory.class);
  
      private final ApplicationEventPublisher eventPublisher;
  
      /**
       * Creates a new instance
       *
       * @param eventPublisher the {@link ApplicationEventPublisher} to use. Cannot be null.
       */
      public WebSocketConnectHandlerDecoratorFactory(ApplicationEventPublisher eventPublisher) {
          Assert.notNull(eventPublisher, "eventPublisher cannot be null");
          this.eventPublisher = eventPublisher;
      }
  
      @Override
      public WebSocketHandler decorate(WebSocketHandler handler) {
          return new SessionWebSocketHandler(handler);
      }
  
      private final class SessionWebSocketHandler extends WebSocketHandlerDecorator {
  
          public SessionWebSocketHandler(WebSocketHandler delegate) {
              super(delegate);
          }
  
          @Override
          public void afterConnectionEstablished(WebSocketSession wsSession)
                  throws Exception {
              super.afterConnectionEstablished(wsSession);
  
              publishEvent(new SessionConnectEvent(this,wsSession));
          }
  
          private void publishEvent(ApplicationEvent event) {
              try {
                  eventPublisher.publishEvent(event);
              }
              catch (Throwable ex) {
                  logger.error("Error publishing " + event + ".", ex);
              }
          }
      }
  }
  </code></pre>