Davide Dell'Olio
Davide Dell'Olio

Reputation: 83

How to configure Spring WebSocket in cluster

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

Upvotes: 5

Views: 2828

Answers (1)

Prakash Hari Sharma
Prakash Hari Sharma

Reputation: 1424

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);
  }

Upvotes: 4

Related Questions