Doubt on broker behaviour with QoS 2

64 views
Skip to first unread message

Paolo Patierno

unread,
Feb 26, 2014, 11:44:26 AM2/26/14
to mq...@googlegroups.com
Hello,
I have a doubt on broker behaviour when there is a message with QoS 2.
Suppose the following scenario...

1. publisher sends PUBLISH message with QoS 2 and messageId = X;
2. broker receives PUBLISH message, inserts it into a queue and then sends PUBREC to the publisher;
3. suppose that PUBREC is lost and it doesn't arrive to the publisher;
4. after a while, the publisher that doesn't see PUBREC from broker, resend PUBLISH message with QoS 2 and messageId = x and dupflag = true;
5. broker receives PUBLISH message but it already has this message in its queue..... (step 2)

How does the broker handle this type of scenario ?

Paolo.

Nicholas O'Leary

unread,
Feb 26, 2014, 12:41:32 PM2/26/14
to mq...@googlegroups.com
When the broker receives the second instance of the publish, it knows it has already seen that publish as it has stored the message ID in a list of incomplete qos 2 messages. This means it doesn't double-process the publish. But it still responds with another PUBREC as it has to complete the flow.

The publisher, when it receives the PUBREC, sends the PUBREL - this notifies the broker it can 'release' the message onwards. It deletes the record it had for the message as processing is now complete, and responds with a PUBCOMP.

If the publisher doesn't receive the pubcomp, it will resend the pubrel. This time, the broker will have no record for the message id in the pubrel (is it was previously deleted with the first pubrel) - the broker just has to respond with a pubcomp in this case so the publisher knows it has been completed.

Nick

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQ Telemetry Transport" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at http://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/groups/opt_out.

Paolo Patierno

unread,
Feb 28, 2014, 10:24:12 AM2/28/14
to mq...@googlegroups.com
Hi Nick...great explanation !

Thanks.
Reply all
Reply to author
Forward
0 new messages