Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Spring WebSocket in cluster

Tags:

I have configured Spring Websocket over Stomp in my project.

My enviroment have 2 cluster node and one balancer. How can configure the spring websocket in cluster mode?

Thanks in advance

like image 966
Davide Dell'Olio Avatar asked Jul 04 '16 11:07

Davide Dell'Olio


1 Answers

You need to use message broker like ActiveMQ / RabbitMQ etc. Either you can set a seperate node for message broker or you can also set it on any node in your 2 cluster node.

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);
  }
like image 136
Prakash Hari Sharma Avatar answered Sep 28 '22 02:09

Prakash Hari Sharma