I have this configuration for Spring and a full feature stomp broker (ActiveMQ):
@Configuration
@EnableWebSocketMessageBroker
public class WebsocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
private static Logger LOG = org.slf4j.LoggerFactory.getLogger(WebsocketConfig.class);
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableStompBrokerRelay("/topic/", "/queue/");
config.setApplicationDestinationPrefixes("/app");
config.setUserDestinationPrefix("/user");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/socket").withSockJS();
}
}
I thought Spring would use my current ActiveMQ configuration, but in reality it tries to connect into a server located in localhost
with a default stomp port. I discovered that is possible to change this configuration by typing:
config.enableStompBrokerRelay("/topic/", "/queue/")
.setRelayHost("activeMQHOST")
.setRelayPort(9999);
Thats fine, but currently I have a failover setup with two brokers. How can I configure such setup for the stomp broker relay?
If not possible, I thought in the following solutions:
- Use the simple (in memory) broker, which isn't advisable.
- The ActiveMQ is used for several operations (not restricted to WebSockets), and I don't know if it is recommended to mix Stomp/WebSockets queues with other feature's queues. Thinking on it, I can create another ActiveMQ instance (maybe using the VM transport).
The second option is advisable?
activemq
that does not have a "correct" answer. It would be good to mark the current answer as correct if it actually is to help other users who have this same problem. If it's not correct it would be helpful to explain why. Thanks! – Telegonus