我设法用Spring 4和Stomp创建了简单的Websocket应用程序。看到我最后的问题here
然后,我尝试使用远程消息代理(ActiveMQ)。我刚开始做经纪人
registry.enableSimpleBroker("/topic");
至
registry.enableStompBrokerRelay("/topic");
而且有效。
问题是如何配置代理?我了解在这种情况下,应用程序会自动在localhost:defaultport上找到代理,但是如果我需要将应用程序指向其他计算机上的某些其他代理,该怎么办?
最佳答案
enableStompBrokerRelay
方法返回一个方便的Registration实例,该实例公开了流畅的API。
您可以使用此流利的API配置您的Broker中继:
registry.enableStompBrokerRelay("/topic").setRelayHost("host").setRelayPort("1234");
您还可以配置各种属性,例如代理的登录/通过凭据等。
与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>
有关属性和默认值的更多详细信息,请参见StompBrokerRelayRegistration javadoc。
关于java - Spring 4 WebSocket Remote Broker配置,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20747283/