title: Stomp over websocket using Spring and sockJS message lost
body: <p>On the client side javascript I have </p>
  
  <pre><code>    stomp.subscribe("/topic/path", function (message) {
          console.info("message received");
      });
  </code></pre>
  
  <p>And on the server side</p>
  
  <pre><code>public class Controller {
    private final MessageSendingOperations&lt;String&gt; messagingTemplate;
    ＠Autowired
    public Controller(MessageSendingOperations&lt;String&gt; messagingTemplate) {
        this.messagingTemplate = messagingTemplate;
    }
    @SubscribeMapping("/topic/path")
    public void subscribe() {
       LOGGER.info("before send");
       messagingTemplate.convertAndSend(/topic/path, "msg");
    }
  }
  </code></pre>
  
  <p>From this setup, I am occasionally (around once in 30 page refreshes) experiencing message dropping, which means I can see neither "message received" msg on the client side nor the websocket traffic from Chrome debugging tool. </p>
  
  <p>"before send" is always logged on the server side.</p>
  
  <p>This looks like that the MessageSendingOperations is not ready when I call it in the subscribe() method. (if I put Thread.sleep(50); before calling messagingTemplate.convertAndSend the problem would disappear (or much less likely to be reproduced))</p>
  
  <p>I wonder if anyone experienced the same before and if there is an event that can tell me MessageSendingOperations is ready or not.</p>