【问题标题】:Java Spring STOMP: Set broker IPJava Spring STOMP:设置代理 IP
【发布时间】:2015-12-29 04:25:30
【问题描述】:

我有一个使用 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?

【问题讨论】:

    标签: java spring stomp spring-websocket


    【解决方案1】:

    您好,您正在使用简单的代理 (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。您可能还需要添加入站和出站通道配置,因为默认通道是一个。单通道负载下的响应将非常慢。 在&lt;websocket:message-broker&gt; and &lt;/websocket:message-broker&gt;标签之间插入下面的sn-p:

    <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 文档中得到这个

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-24
      • 2017-08-06
      • 1970-01-01
      • 1970-01-01
      • 2017-07-30
      • 2020-02-04
      • 1970-01-01
      相关资源
      最近更新 更多