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

发布于 2025-02-09 15:19:25 字数 463 浏览 3 评论 0原文

我们构建服务器以从另一台MQTT服务器订阅主题。当我们只有一台服务器时,它可以很好地工作。但是,当我们将其扩展到多个服务器时,它就出错了。由于每个服务器都会从订阅中收到相同的消息,因此所有服务器都会多次执行。

mqtt v5 问题:

  1. mqtt.js 支持此功能吗?我在文档中找不到它。
  2. 如果我们仍在使用MQTT v3.1.1,请使用任何替代解决方案来解决此问题?

We build the server to subscribe the topics from another MQTT server. 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:

  1. Is the MQTT.js supports this feature? I cannot find it in the documentation.
  2. If we are still using MQTT v3.1.1, any alternative solution to solve this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一杆小烟枪 2025-02-16 15:19:25
  1. 客户端无需采取任何行动来支持共享订阅,因为这一切都使用了主题前缀。这意味着mqtt.js的工作正常。
  2. 在MQTT v3.1.1级别工作时,有一些MQTT经纪人支持共享订阅。在编写了V5.0规格之前完成了不同的经纪实施,但规格非常基于这些实现,因此它们以非常相似的方式工作。

关于共享订阅的工作方式,也没有任何MQTT v5.0具体的(新标头空间中的没有),因此没有理由为什么它不应适用于连接到v3.1.1/v5.0的v3.1.1客户端。提供共享订阅功能的兼容经纪人。

我不记得哪个经纪人在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.
  2. There are some MQTT brokers that have support for Shared Subscriptions while working at MQTT v3.1.1 level. 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.

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.

I can't remember which brokers supported it at v3.1.1 so you will have to check which broker you are using.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文