title: Spring websocket and Stomp.js - how long should i wait between subscribe and send?
body: <p>I have the following code (from the spring websocket demo app) :</p>
  
  <pre><code>    stompClient.connect({}, function(frame) {
          setConnected(true);
          console.log('Connected: ' + frame);
          stompClient.subscribe('/user/queue/greeting', function(greeting) {          
              displayQueueMessage(greeting);
          });
  
      function sendName() {
        var name = document.getElementById('name').value;
        stompClient.send("/app/wsdemo", {}, JSON.stringify({
          'name' : name
         }));
      }
  </code></pre>
  
  <p>This is a simple subscribe call for a queue on the server, and another method "sendName()" that sends calls the server.</p>
  
  <p>after sendName is called, the server response to the callback function supplied at the connect method:</p>
  
  <pre><code>function(greeting) {            
      displayQueueMessage(greeting);
  });
  </code></pre>
  
  <p>My question is - how "long" should the client wait from the <strong>subscribe</strong> call until he can start calling <strong>sendName</strong> ?   I mean, the potential issue i can see here is the following:</p>
  
  <p>i) the client subscribes first for the queue,</p>
  
  <p>ii) the client calls sendName</p>
  
  <p>iii) the server recieves the 2nd call before he recieves the subscribe call.</p>
  
  <p>iv) the response from the server will not be recieved by the client.</p>
  
  <p><strong>my questions:</strong></p>
  
  <p>1) is that scenario really is an issue? </p>
  
  <p>2) how can i avoid it? </p>
  
  <p>3) iv'e read somewhere that since websocket works with tcp, the order of messages is maintained, so my last question is - what about the fallback capability of stompJS for clients with no websocket support? will the order be maintained as well?</p>