具有负载平衡应用服务器的MQTT [英] MQTT with load balanced applicaiton server

查看:103
本文介绍了具有负载平衡应用服务器的MQTT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个运行相同Web应用程序的tomcat服务器.两个Web应用程序都订阅了MQTT服务器中的主题1.每当在主题1中接收到消息时,两个应用程序都会接收到该消息.但是我只希望一台服务器处理请求,而不是两者都处理.最坏的情况是我必须在两个Web应用程序上进行条件检查,以允许一次处理.对于这种情况有什么建议吗?

I am having two tomcat servers running same web application. Both the web applications subscribe to topic 1 in MQTT server. Whenever message is received in topic 1 both the applications receive the message. But I want only one server to process the request instead of both. The worst case I have to do condition check at both the web applications to allow one time processing. Any suggestions for this case ?

推荐答案

您需要使用支持共享订阅的MQTT代理 1

You need to use a MQTT broker that supports Shared Subscriptions1

此功能使您可以让多个客户端订阅相同的主题,并且代理将以循环方式将它们传递给所有客户端(例如,向客户端1发送第一条消息,向客户端2发送第二条消息,向客户端2发送第三条消息,向客户端1发送第一条消息,客户端2的第4位...)

This feature allows you to have multiple clients subscribed to the same topic and the broker will deliver them in a round-robin fashion to all the clients (e.g. first message to client 1, second to client 2, 3rd to client 1, 4th to client 2...)

1 共享订阅是许多在v3实施的代理的功能,但是它们具有不同的机制,因此它们并不总是兼容的,从MQTT规范的v5开始,共享订阅是代理可以选择的组件支持和实现该功能的所有代理的行为都应相同.

1 Shared Subscriptions was a feature a number of brokers implemented at v3 but with different mechanisms so they were not always compatible, as of v5 of the MQTT spec Shared Subscriptions is an optional component the broker can support and all brokers that implement the feature should behave the same.

这篇关于具有负载平衡应用服务器的MQTT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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