我有一个使用Spring的Java应用程序使用Websocket,只要RabbitMQ在与tomcat相同的机器上运行,它就能正常工作。
如何设置RabbitMQ的IP?我正在阅读文档但我找不到它。
我目前的配置与one in the documentation
非常相似<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:websocket="http://www.springframework.org/schema/websocket"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/websocket
http://www.springframework.org/schema/websocket/spring-websocket.xsd">
<websocket:message-broker application-destination-prefix="/app">
<websocket:stomp-endpoint path="/portfolio">
<websocket:sockjs/>
</websocket:stomp-endpoint>
<websocket:simple-broker prefix="/topic, /queue"/>
</websocket:message-broker>
</beans>
如何设置IP?
答案 0 :(得分:1)
您好,您正在使用简单的经纪人(&lt; websocket:simple-broker prefix="/topic, /queue"/>
)。尝试使用以下设置:
<websocket:message-broker application-destination-prefix="/app">
<websocket:stomp-endpoint path="/ws">
<websocket:sockjs/>
</websocket:stomp-endpoint>
<websocket:stomp-broker-relay prefix="/topic"
relay-host="${websocket.relay.host}" relay-port="61613" client-login="user" client-passcode="passwd" system-login="user" system-passcode="passwd"
heartbeat-send-interval="20000" heartbeat-receive-interval="20000"/>
</websocket:message-broker>
此配置将帮助您添加IP。您可能还需要添加入站和出站通道配置,因为默认通道是一个。单个通道响应的负载将非常慢。
在<websocket:message-broker> and </websocket:message-broker>
代码之间插入以下代码段:
<websocket:client-inbound-channel>
<websocket:executor core-pool-size="50" max-pool-size="100" keep-alive-seconds="60"/>
</websocket:client-inbound-channel>
<websocket:client-outbound-channel>
<websocket:executor core-pool-size="50" max-pool-size="100" keep-alive-seconds="60"/>
</websocket:client-outbound-channel>
<websocket:broker-channel>
<websocket:executor core-pool-size="50" max-pool-size="100" keep-alive-seconds="60"/>
</websocket:broker-channel>
如果您的rabbitmq服务器与应用程序不同,您还需要添加登录凭据。为此,您需要更改配置文件。你可以在RabbitMQ文档中获得这个