Does MQTT maintains a queue internally for each topic

49 views
Skip to first unread message

Nithin B

unread,
Mar 13, 2018, 2:18:33 PM3/13/18
to MQTT
I got a doubt that does MQTT server will maintain a queue for a particular topic.

Test: In c#

I created a publisher and subscriber for a topic and published continuously topic value as 1 to 100. 
But in subscriber side I kept sleep for 2 seconds.

Settings on publishing: retain is false and with publish_exactly_once option.

Now its like subscriber will process one value for 2 seconds.

Result:

It worked as excepted but at times one value is coming at end like 1 to 100(except 56) came and 56 came's at last.

Why could this be happening?

And also how does it work with multiple topics. Will it publish like FIFO? Is there any limit for the queue for each topic?

With regards,
Nithin B.

Karl Palsson

unread,
Mar 13, 2018, 7:21:25 PM3/13/18
to mq...@googlegroups.com

Nithin B <nithin....@gmail.com> wrote:
> I got a doubt that does MQTT server will maintain a queue for a
> particular topic.

It doesn't, and isn't meant to, so the rest of your test, (which
I admit I don't really understand) isn't relevant.

An MQTT broker will maintain queues _per client_ for each
subsciption. If the client disconnects and reconnects, those
queues are only kept if the client was connecting with
clean_session=false, and only if the messages were originally
_published_ at qos >= 1, and the client subscription was _also_
at qos >= 1, _and_ if the client id was the same.

Cheers,
Karl P
signature.html

Nithin B

unread,
Mar 14, 2018, 12:53:26 AM3/14/18
to MQTT
@Karl Palsson Thanks for the reply.

I am setting MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE(2) and retain as false.

Now according to you, it means that it will maintain a queue for connected client.

But what surprising is when I am publishing from 1 to 100 using for loop it should have added into the queue in correct ascending order form 1 to 100. But how come one or the other number(in my case once 56 once 63...random) is coming after 100.

Can you see any reason for happening this?

With regards,
Nithin B.


Reply all
Reply to author
Forward
Message has been deleted
0 new messages