How to configure Spring WebSocket in a cluster

I configured Spring Websocket on top of Stomp in my project.

In my environment there are 2 node clusters and one balancer. How to configure Spring web layout in cluster mode?

Thanks in advance

+4
source share
1 answer

You need to use a message broker such as ActiveMQ / RabbitMQ, etc. Either you can install a separate node for the message broker, or you can install it on any node in your 2-node cluster.

The next thing you need to configure enableStompBrokerRelay in your WebSocketConfig on both nodes.

  @Override
  public void configureMessageBroker(MessageBrokerRegistry config) {
    config.setApplicationDestinationPrefixes("/app");
    config.enableStompBrokerRelay("/topic","/queue").setRelayHost("MQHOSTNAME").setRelayPort(MQPORT);
  }
+2
source

All Articles