1
votes

From what I can tell, MQTT QOS is all about Client -> Broker delivery agreements, ie, QOS 1 and 2 can ensure that a published message is received by the broker.

Paho does a good job of blocking based on this basis; mqttClient.publish will block until the QOS defined agreement is completed - between the client publishing and the broker.

However, if I have clientA publish a message intended for clientB, how do I block until clientB has received the message from the broker?

eg:

ClientB->Subscribe("peer-device/ClientB/application/message")
ClientA->Publish("peer-device/ClientB/application/message")
1

1 Answers

0
votes

The short answer is you don't

Each client has absolutely no idea if any other clients are subscribed to any given topics and this is by design. MQTT is Pub/Sub, not a point-to-point protocol. Part of the point of Pub/Sub architectures is to fully decouple publishers from subscribers

MQTT QOS covers both publisher to broker and broker to subscriber but as 2 distinctly separate steps. The first leg ensures the message reaches the broker (for QOS 1 or 2) and the second leg ensures that the message reaches any subscribers.