[英]Spring 4 WebSocket Remote Broker configuration
I managed to create simple Websocket application with Spring 4 and Stomp. 我设法用Spring 4和Stomp创建简单的Websocket应用程序。 See my last question here Then I tried to use remote message broker(ActiveMQ).
在这里查看我的上一个问题然后我尝试使用远程消息代理(ActiveMQ)。 I just started the broker and changed
我刚开始经纪人并改变了
registry.enableSimpleBroker("/topic");
to 至
registry.enableStompBrokerRelay("/topic");
and it worked. 它起作用了。
The question is how the broker is configured? 问题是如何配置代理? I understand that in this case the application automagicaly finds the broker on localhost:defaultport, bu what if I need to point the app to some other broker on other machine?
据我所知,在这种情况下,应用程序自动发现localhost上的代理:defaultport,如果我需要将应用程序指向其他机器上的其他代理,该怎么办?
The enableStompBrokerRelay
method returns a convenient Registration instance that exposes a fluent API. enableStompBrokerRelay
方法返回一个方便的Registration实例,该实例公开了一个流畅的API。
You can use this fluent API to configure your Broker relay: 您可以使用此流畅的API来配置您的Broker中继:
registry.enableStompBrokerRelay("/topic").setRelayHost("host").setRelayPort("1234");
You can also configure various properties, like login/pass credentials for your broker, etc. 您还可以配置各种属性,例如代理的登录/传递凭据等。
Same with XML Configuration: 与XML配置相同:
<websocket:message-broker>
<websocket:stomp-endpoint path="/foo">
<websocket:handshake-handler ref="myHandler"/>
<websocket:sockjs/>
</websocket:stomp-endpoint>
<websocket:stomp-broker-relay prefix="/topic,/queue"
relay-host="relayhost" relay-port="1234"
client-login="clientlogin" client-passcode="clientpass"
system-login="syslogin" system-passcode="syspass"
heartbeat-send-interval="5000" heartbeat-receive-interval="5000"
virtual-host="example.org"/>
</websocket:message-broker>
See the StompBrokerRelayRegistration javadoc for more details on properties and default values. 有关属性和默认值的更多详细信息,请参阅StompBrokerRelayRegistration javadoc。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.