title: Handling Spring Boot Clustered Websockets on Amazon Beanstalk
body: <p>I have an application using Spring Framework / Spring Boot / Spring Messaging/Websockets and am going to be deploying it to Elastic Beanstalk.  You can think of the application as a chat application (it actually does have chat features)  </p>
  
  <p><strong>Scenario</strong></p>
  
  <p>Here is an example scenario:</p>
  
  <pre><code>Client A &lt;-&gt; Server A
  Client B &lt;-&gt; Server B
  Client C &lt;-&gt; Server B
  </code></pre>
  
  <p>Now, if <code>Client A</code> posts a message, using spring messaging, if I send that message to all connected clients, only <code>Client A</code> will see it because only <code>Client A</code> is connected to <code>Server A</code>, and likewise if <code>Client B</code> does, only <code>Clients B and C</code> will see it, not <code>Client A</code>.</p>
  
  <p>So this leaves me with a problem of what options I have.</p>
  
  <p><strong>Possible Solutions</strong></p>
  
  <p>If possible, I would like to use an Amazon service as I am already in their cloud platform.  </p>
  
  <p>I thought about using Amazon SQS, having each server subscribe to the same queue, and then sending all notifications through it, but I believe all requests with SQS are active, so I would have to do polling, and would create a significant delay.</p>
  
  <p>Does anyone know of a good solution for this problem?  I can set up a server to handle all web-sockets, but that is not optimal.  </p>
  
  <p>Thanks in advance!</p>