【问题标题】:Fail to connect to Rabbitmq using Spring 4.0 webstocket stomp api使用 Spring 4.0 webstocket stomp api 连接到 Rabbitmq 失败
【发布时间】:2014-02-13 20:46:05
【问题描述】:

我尝试使用 Spring 4.0 WebSocketMessageBrokerConfigurer 类与 RabbitMQ 建立 STOMP 连接,但失败了?

代码快照在这里。

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

注意

  • 我正在使用 spring boot 来运行应用程序。事实上,我正在更改现有的 spring 示例“gs-messaging-stomp-websocket”。和换班WebSocketConfig
  • Rabbitmq 在本地安装并启用了 STOMP 插件。
  • 添加了所有的 maven 依赖,比如 spring-rabbitmq。

我还需要做其他事情吗?

谢谢, 拉菲克

【问题讨论】:

    标签: rabbitmq spring-4 spring-messaging spring-websocket


    【解决方案1】:

    好的,问题解决了

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

    我们需要传递 stomp 支持的 "uri" 而不是 "/" vhost。

    StompBrokerRelayRegistration StompBrokerRelayRegistration = config.enableStompBrokerRelay("/topic", "/queue", "/amq/");
    

    【讨论】:

    • 你好@Rafiq 你能发布你的完整单脚配置吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-14
    • 1970-01-01
    • 2016-06-08
    • 2018-07-07
    • 1970-01-01
    • 2021-09-27
    • 2013-02-06
    相关资源
    最近更新 更多