我正在 Spring 4 中使用内置的消息代理和基于 WebSocket 的 STOMP 开发一个实时通知系统。
我想处理存在多应用程序服务器且用户目标未解析(因为用户连接到另一台服务器)的情况。 Spring 文档声称有一个解决方案:
In a multi-application server scenario a user destination may remain unresolved because the user is connected to a different server. In such cases you can configure a destination to broadcast unresolved messages to so that other servers have a chance to try. This can be done through the userDestinationBroadcast property of the MessageBrokerRegistry in Java config and the user-destination-broadcast attribute of the message-broker element in XML.
但是没有这样配置的例子。如何设置服务器以接收这些消息和系统 channel 的身份验证参数?
最佳答案
在处理基于 STOMP 的 WebSockets 的多节点应用程序时,您必须配置和使用外部 STOMP Broker(例如 RabbitMQ),以便不同的应用程序实例可以相互通信。你已经在做了,对吧?
为了配置 userDestinationBroadcast
和 userRegistryBroadcast
只需为它们分配一个目的地名称。当应用程序启动并在应用程序和代理之间建立系统 TCP 连接时,这些目的地将自动创建,一切都会正常且透明地工作。
我使用 Spring WebSockets、RabbitMQ 等编写了一个网络聊天应用程序,其配置为 available here .
希望对您有所帮助。
关于java - Spring stomp 多应用服务器的配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43007984/