mqttmosquittolibmosquitto

Mosquitto fire only one for each topic


I implemented a MQTT message broker using mosquitto on my network. I have one web app publishing things to the broker and several servers that subscribed the same topic. So i have a redundancy scenario.

My question is, using mosquitto alone, is there any way to configure it to publish data only on the first subscriber? Otherwise, all of them will do the same thing.


Solution

  • I don't think that is possible.

    But you can do this.

    Have the first subscriber program respond with an ack on the channel as soon as it gets the message, and have the redundancy program look for the ack for a small time after the initial message.

    IF the ack is received the redundancy should not do anything.

    So if the first subscriber gets and uses the message, the others wont do anything even if they get the message.