Question

I tried to make STOMP connection to RabbitMQ using Spring 4.0 WebSocketMessageBrokerConfigurer class, but failed ?

Snap of code is here.

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {

    @Override
    public void configureMessageBroker(MessageBrokerRegistry config) {
        StompBrokerRelayRegistration StompBrokerRelayRegistration = config.enableStompBrokerRelay("/");
        StompBrokerRelayRegistration.setApplicationLogin("guest");
        StompBrokerRelayRegistration.setApplicationPasscode("guest");
        StompBrokerRelayRegistration.setAutoStartup(true);
        StompBrokerRelayRegistration.setRelayHost("localhost");
        StompBrokerRelayRegistration.setRelayPort(15674);

Note that

  • I am using spring boot to run application. In fact I am changing the existing spring example "gs-messaging-stomp-websocket". and changing class WebSocketConfig.
  • Rabbitmq is locally installed with STOMP plugin enabled.
  • Added all the maven dependency like spring-rabbitmq.

Do I need to do any thing else ?

Thanks, Rafiq

Was it helpful?

Solution

Ok got the issue

StompBrokerRelayRegistration StompBrokerRelayRegistration = config.enableStompBrokerRelay("/");

We need to pass the stomp supported "uri" instead of "/" vhost.

StompBrokerRelayRegistration StompBrokerRelayRegistration = config.enableStompBrokerRelay("/topic", "/queue", "/amq/");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top