Spring 4 WebSocket Remote Broker配置 [英] Spring 4 WebSocket Remote Broker configuration

查看:114
本文介绍了Spring 4 WebSocket Remote Broker配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法用Spring 4和Stomp创建了简单的Websocket应用程序.在此处查看我的最后一个问题. 然后,我尝试使用远程消息代理(ActiveMQ).我刚刚启动经纪人并更改了

I managed to create simple Websocket application with Spring 4 and Stomp. See my last question here Then I tried to use remote message broker(ActiveMQ). I just started the broker and changed

registry.enableSimpleBroker("/topic");

registry.enableStompBrokerRelay("/topic");

成功了.

问题是如何配置代理?我了解在这种情况下,应用程序会自动在localhost:defaultport上找到代理,但是如果我需要将应用程序指向其他计算机上的其他代理,该怎么办?

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?

推荐答案

enableStompBrokerRelay方法返回一个方便的Registration实例,该实例公开了流畅的API.

The enableStompBrokerRelay method returns a convenient Registration instance that exposes a fluent API.

您可以使用此流利的API配置您的Broker中继:

You can use this fluent API to configure your Broker relay:

registry.enableStompBrokerRelay("/topic").setRelayHost("host").setRelayPort("1234");

您还可以配置各种属性,例如代理的登录/通过凭据等.

You can also configure various properties, like login/pass credentials for your broker, etc.

与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,以获取有关属性和默认值的更多详细信息.

See the StompBrokerRelayRegistration javadoc for more details on properties and default values.

这篇关于Spring 4 WebSocket Remote Broker配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆