使用spring4 stomp和socksjs应用程序配置rabbitmq

w8biq8rn  于 2022-11-08  发布在  RabbitMQ
关注(0)|答案(1)|浏览(164)

我有问题与spring 4+Stomp+socks js应用程序。它是工作正常的简单消息代理,但当切换到rabbitmq,它是不工作的,无法解决它与答案提到的配置外部代理(rabbitMQ)在spring 4 +STOMP+SockJS应用程序
我的代码是:

<websocket:message-broker application-destination-prefix="/app">
    <websocket:stomp-endpoint path="/hello">
        <websocket:sockjs/>
    </websocket:stomp-endpoint>
    <websocket:stomp-broker-relay prefix="/topic" system-login="guest" system-passcode="guest" client-login="guest"
                                  client-passcode="guest" relay-host="localhost" relay-port="15672"/>
</websocket:message-broker>

控制器:

@Controller
public class StompController {

    @MessageMapping("/hello")
    @SendTo("/topic/greetings")
    public Greeting greetUser(User user) throws Exception {
        Thread.sleep(3000); // simulated delay
        return new Greeting("Hello, " + user.getName() + "!");
    }

}

詹:

function connect() {
            var socket = new SockJS('/hello');
            stompClient = Stomp.over(socket);
            stompClient.connect('guest','guest', function(frame) {
                setConnected(true);
                console.log('Connected: ' + frame);
                stompClient.subscribe('/topic/greetings', function(greeting){
                    showGreeting(JSON.parse(greeting.body).content);
                });
            });
        }

一边连线一边说:
SEVERE [clientInboundChannel-1]组织.Spring框架.消息传递.简单.stomp.stompBrokerRelayMessageHandler.处理消息内部**消息代理未处于活动状态.**忽略:[有效载荷字节[0]][报头={stompCommand=CONNECT,stompCredentials=[受保护],本机报头={心跳=[10000,10000],密码=[受保护],登录=[访客],接受版本=[1.1,1.0]},简单消息类型=CONNECT,简单会话属性={},简单会话ID =ih_04mxa,id= d36 fc 1c 1-e00 c-fb 48 - 51 af-c526 e3018 e20,时间戳=1413617272621}]
我甚至在兔子mq中启用了stomp插件。

wvmv3b1j

wvmv3b1j1#

停止油口

我认为Spring无法连接到您的RabbitMQ示例,因为您将其指向端口15672,我认为这一定是Web UI或其他东西的默认端口。The default port for the STOMP connector with rabbitMQ is 61613(实际上这是Spring选择的默认值)。您可以尝试使用该端口吗?

访问控制

此外,您一定要考虑您的访问控制配置as the guest user won't work remotely

相关问题