Lifespan of a message in a topic

Hi Team,
What is the life span of a message which has been published to a topic.

For a topic, no one has subscribed, will the topic holds the message, if yes, then for how long it will hold.

Also, is there any data size limitation(day or month wise or in some other form) on the broker??

Regards,
Viswanath Vankadari

1 Like

Hello @ViswanathDR ,

Thank you for the outreach, and the interest in MQTT!

MQTT functions with a Publish and Subscribe model. This means that, when a publisher publishes to a topic, it will be distributed to subscribers of that topic by the broker. If there is no subscriber for a particular topic, there will be no client to receive the message, and therefore the message will not be stored or distributed to other clients. Note that if there are clients that are subscribers and they are currently offline, the retention of the message will be determined by a variety of factors - the QoS level of the published message, the queue status for the relevant subscribing clients, and any additional queue specifications that have been set within the broker itself. Some more details on how this work is covered in our MQTT essentials series, available here, which I highly recommend!

Note that, additionally, MQTT offers functionality called Retained Messages - this allows a message to be retained for a specific topic, so when a new client subscribers to a topic it will immediately receive this retained message. More details on retained messages can be found here.

Best,
Aaron from the HiveMQ Team