简体   繁体   English

MQTT共享订阅解决分布式系统中的重复问题

[英]MQTT shared subscriptions to solve the duplicated issue in the distributed system

We build the server to subscribe the topics from another MQTT server.我们构建服务器以从另一个 MQTT 服务器订阅主题。 It works perfectly when we have only one server.当我们只有一台服务器时,它可以完美运行。 However, when we scale it to multiple servers it went wrong.但是,当我们将其扩展到多台服务器时,它就出错了。 Because each of servers receive the same message from the subscription, everything performs multiple times.因为每个服务器都从订阅中接收到相同的消息,所以一切都会执行多次。

MQTT v5 solves this problem, but I have the 2 questions: MQTT v5解决了这个问题,但我有两个问题:

  1. Is the MQTT.js supports this feature? MQTT.js是否支持此功能? I cannot find it in the documentation.我在文档中找不到它。
  2. If we are still using MQTT v3.1.1, any alternative solution to solve this problem?如果我们仍在使用 MQTT v3.1.1,有什么替代方案可以解决这个问题?
  1. The client side doesn't need to do anything to support Shared Subscriptions as it's all done with a topic prefix.客户端不需要做任何事情来支持共享订阅,因为它都是通过主题前缀完成的。 This means MQTT.js will work just fine.这意味着 MQTT.js 可以正常工作。
  2. There are some MQTT brokers that have support for Shared Subscriptions while working at MQTT v3.1.1 level.有一些 MQTT 代理在 MQTT v3.1.1 级别工作时支持共享订阅。 The different broker implementation were done before the v5.0 spec was written but the spec was very much based on these implementations so they work in a very similar fashion.不同的代理实现是在编写 v5.0 规范之前完成的,但规范非常基于这些实现,因此它们以非常相似的方式工作。

There is also nothing MQTT v5.0 specific about how Shared Subscriptions work, (nothing in the new header space) so there is no reason why it shouldn't work for a v3.1.1 client connecting to a v3.1.1/v5.0 compatible broker that offers the Shared Subscription feature. MQTT v5.0 也没有具体说明共享订阅的工作方式(新标头空间中没有任何内容),因此没有理由为什么它不适用于连接到 v3.1.1/v5.0 的 v3.1.1 客户端提供共享订阅功能的兼容代理。

I can't remember which brokers supported it at v3.1.1 so you will have to check which broker you are using.我不记得在 v3.1.1 中哪些代理支持它,因此您必须检查您使用的是哪个代理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM