How to configure Time to Live (ToL) for messages belong to a hierarchy topic

Hi All

I have two sp/qa/device/rt-veh/event and sp/qa/device/rt-veh/vehicles
How to configure Time to Live (ToL) for messages belong to a hierarchy topic of sp/qa/device/rt-veh/vehicles to available for 24 hours.

Alos, can you please let me know what is the default tTime to Live (ToL) for a message

Thank you for your help and support

Regards, Bao

2 Likes

Hi Bao,

one essential principle in MQTT, especially when you’re coming from other messaging protocols, is this:

A topic is not a queue.

In other words, messages do not live in such a ‘topic-queue’ for which you could set properties. However, there is a property called “Message Expiry Interval” in v5 of MQTT. It is set by the publishing client, not the broker. See the reference here: MQTT Version 5.0

So the publisher could set a Message Expiry Interval of 24h, yes. Note that a new consumer cannot connect to the broker later and get those messages. It needs an (online or offline) session with a matching subscription when/before the PUBLISH comes in at the broker.

2 Likes