2015-12-29 64 views
0

我有一個使用Spring的Java應用程序,它使用Websocket,只要RabbitMQ與tomcat運行在同一臺計算機上,它就可以正常工作。Java Spring STOMP:設置代理IP

如何設置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?

回答

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。您可能還需要添加入站和出站通道配置,因爲默認通道爲1。單通道響應下的負載將非常緩慢。下面 插入代碼段中<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文檔中得到這個