Pergunta

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

Foi útil?

Solução

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/");
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top