"Stale" publishes to topic

35 views
Skip to first unread message

Ryan Benoit

unread,
Oct 22, 2015, 6:56:30 PM10/22/15
to MQTT
Hello,

We have an interesting problem and I was wondering if we are missing something within the MQTT spec or if it can't be managed using MQTT current. Our setup is something like the following:

MQTT broker (Mosquitto) with persistence

An mqtt client (Client A) which has clean session : false and subscribes to /some/topic with qos : 1

Client A goes offline for a while

Another MQTT Client (client B) which publishes a message to /some/topic with qos of 1 and retain : true (payload='hello')

Client B then publishes another message to /some/topic with qos of 1 and retain : true (payload='start')

Client A reconnects and gets published 2 messages for the topic

Is there anyway for us to ensure that Client A when it reconnects it only gets the latest message (payload='stop') instead. We want to make sure that message is delivered though hence the Qos 1.

Thanks for you help.

Ryan 


Darren Clark

unread,
Oct 24, 2015, 2:54:07 AM10/24/15
to mq...@googlegroups.com

If you want that behavior, you should use cleansession=true. Then messages sent while your client is offline will not be delivered. If what you want is to have missed non-retained messages delivered, but only the latest retained message, the  you're out of luck. Retained messages are handled just like any other message, except that additionally they are stored and delivered to new clients when they subscribe.

-Darren


This e-mail communication is confidential and legally privileged. If you are not the intended recipient, please notify me at the telephone number shown above or by return e-mail and delete this communication and any copy immediately. Thank you.

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" 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/d/optout.

Hans Jespersen

unread,
Oct 31, 2015, 4:58:29 PM10/31/15
to MQTT
What you describe is a Last Value Queue (LVQ) and is not covered explicitly in the Mqtt spec. It's possible however to program or configure some Mqtt brokers to operate this way and the Solace message broker is an example. It provides this functionality by bridging Mqtt topics into a LVQ and then back into Mqtt topics again. For full discloser, I know this because Solace is my employer.

Another similar but not identical approach is to implement Time To Live (TTL) on messages and age out the older stored messages. I don't think TTL is in the MQTT wire protocol either though so it would also be a non standard setup as well. Also you can still get more than one message at the subscriber this way unless the messages are published at a set consistent rate known to be in perfect sync with the time to live period.

Reply all
Reply to author
Forward
0 new messages