Xim123
Xim123

Reputation: 165

Publish multiple topics in one message 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.

Upvotes: 2

Views: 7587

Answers (1)

hardillb
hardillb

Reputation: 59608

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.

Upvotes: 3

Related Questions