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