在一条消息中发布多个主题 MQTT [英] Publish multiple topics in one message MQTT

查看:115
本文介绍了在一条消息中发布多个主题 MQTT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从不同传感器收集大量数据的设备,我想通过一条消息将它们发送给我的经纪人.在客户端,我只想在给定时间查看其中的一些数据,我不想查看所有数据.我可以在一条消息中发布多个主题,然后在客户端只看到其中的一些主题吗?我知道我可以使用通配符 # 订阅多个主题,但我不知道如何在一条消息中发送多个主题.一种解决方案是在不同的消息中分别发送每个主题,但我有很多传感器,而且速度会很慢.

I have a device that collects a large amount of data from different sensors and I want to send them to my broker in a single message. On the client side, I just want to see some of that data at a given time, I do not want to see them all. Can I publish several topics in a message and then on the client side see only some of these topics? I know that I can subscribe to several topics with the wildcard # but I do not know how to send several topics in a single message. One solution is to send each topic separately in different messages, but I have a lot of sensors and it would be very slow.

推荐答案

不,消息只有一个主题和一个负载.整个有效负载将传送给订阅该主题的每个客户端.

No, messages only have a single topic and a single payload. The whole payload will be delivered to every client that is subscribed to that topic.

您可以让另一个客户端订阅该消息,然后将其分解为单独的部分,并在单独的主题上重新发布这些部分,以按照您希望的方式分发数据.

You could have another client subscribe to the message and then break it up into separate parts and republish those parts on separate topics to distribute the data how you want to receive it.

这篇关于在一条消息中发布多个主题 MQTT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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