java – Spring 4 WebSocket远程代理配置
发布时间:2020-12-14 23:46:30 所属栏目:Java 来源:网络整理
导读:我设法用 Spring 4和Stomp创建简单的Websocket应用程序.请参阅我的上一个问题 here 然后我尝试使用远程消息代理(ActiveMQ).我刚开始经纪人并改变了 registry.enableSimpleBroker("/topic"); 至 registry.enableStompBrokerRelay("/topic"); 它起作用了. 问题
我设法用
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. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |