Spring 4 websocket + stomp + rabbitmq 和集群 [英] Spring 4 websocket + stomp + rabbitmq and clustering

查看:88
本文介绍了Spring 4 websocket + stomp + rabbitmq 和集群的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习 Spring 4 websocket + stomp + rabbitmq(RabbitMQ-Web-Stomp 插件)架构,我有一个关于集群的问题.根据我的理解,Spring MVC 充当 STOMP 请求的网关.如果我们使用 spring web socket 配置集群应用程序实例会造成任何混乱吗?例如,它会打开多个侦听器,在这种情况下,该架构将如何表现?

I am going through Spring 4 websocket + stomp + rabbitmq(RabbitMQ-Web-Stomp plugin) architecture and I have a question about clustering. As per my understanding here Spring MVC act as a gateway for STOMP requests. If we cluster the application instance with spring web socket configuration will it create any confusion? For an example will it open multiple listeners and how will in such a case this architecture behave?

推荐答案

在这种情况下,您需要使用负载平衡和消息代理.我使用 HAProxy 对运行在 4 个 tomcat 服务器上的 4 个 Spring MVC 实例(websocket)进行负载平衡.还将rabbit mq 配置为代理.从客户端代码连接到单个 HAProxy url.

In this scenario, you would need to use load balancing and a message broker. I used HAProxy to load balance 4 Spring MVC instances (websocket) running on 4 tomcat servers. Also configure rabbit mq as a broker. From client code connect to the single HAProxy url.

如果您不使用消息代理,则 websocket 客户端订阅将在应用程序/网络服务器 (tomcat) 的 JVM 中维护,如果一个实例出现故障,则该实例上的所有订阅都将丢失.

If you don't use the message broker, then the websocket client subscriptions will be maintained in the app/ web server's (tomcat) JVM and in case one instance goes down, all the subscriptions on that would be lost.

这篇关于Spring 4 websocket + stomp + rabbitmq 和集群的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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