0
votes

I have a small doubt about using MQTT in my project. I just wanted to know if it is possible that I use RaspberryPi as MQTT broker (server) to receive data from a device which is publishing in MQTT and then at the same time this RaspberryPi publishes the same data in MQTT to another subscriber? If it is possible, then what would be the message broker in the second part? I mean, I want the RaspberryPi to be the device controller(to act on the device data) and at the same time to publish the data to another MQTT subscriber. Is this possible?

Thank you so much, Pouya

2

2 Answers

3
votes

Pub/sub protocols like MQTT support a one to many approach to data delivery. The broker is the central distribution point for data can handle many different clients.

When a client published a message the broker will deliver that message to all clients that have subscribed to the topic that message is published to.

You can run multiple clients on the same machine each publishing, subscribing or both at the same time

0
votes

Actually, this is what MQTT do!

If Device A (Publisher) publish a message in a Topic say: pi-topic/xxxx to MQTT Broker running in Raspberry Pi.Then you just make you Device B (Subscriber) to subscribe/listen to the same topic i.e pi-topic/xxxx .In this way, you can achieve it.You can use any library like Paho.

You need to read further about PUB-SUB models and Queue mechanism .It will help in future.