In this episode of MQTT Essentials series, we will talk about MQTT Retained Messages.
👉 What is a Retained Message in MQTT?
A retained message in MQTT is a topic's last known good value persisted by the broker. The broker stores the last retained message and the corresponding QoS for that topic. Each client that subscribes to a topic pattern that matches the topic of the retained message receives the retained message immediately after they subscribe. The broker stores only one retained message per topic.
Retained messages
are useful when a start state is required
ensure that clients get the last stored value immediately after subscription
Sending retained messages
From the perspective of a developer, sending a retained message is quite simple and straight-forward. You just set the retained flag of an MQTT publish message to true. Typically, your client library provides an easy way to set this flag.
subscribers receive the message immediately (even if they were offline when the message was published)
this solves the empty start value problem
only one retained message per topic is stored by the broker
Queued vs. retained messages
Retained messages: work on a topic level, newly-connected subscribers to a topic receive messages immediately
Queued messages: work in a client context, the broker queues undelivered messages for a specific client
Deleting retained messages:
not necessary in most cases
a new retained message overwrites the old one
to delete: send a retained message with an empty payload
** Chapters / Table of Contents **
00:00 Introduction to MQTT Retained Messages
00:22 What is a Retained Message in MQTT?
01:07 Sending retained messages in MQTT
02:08 Queued vs. retained messages in MQTT
03:41 How to delete a retained message in MQTT
04:31 Announcing part 10 - Last Will & Testament in MQTT
👉 If you missed Part 1 - What is MQTT, watch it now: • What is MQTT | MQTT Essentials Part 1
👉 We also explain the MQTT Retained Messages in detail in the HiveMQ blog here: https://bit.ly/2UuD2HG
👉 We also explain the core of MQTT concepts, its features, and other essential information on the HiveMQ blog: https://bit.ly/3F7l2pm
👉 Get your own MQTT Essentials in a comprehensive, free E-Book: https://bit.ly/3D17jhJ
👉 To know about HiveMQ: https://bit.ly/3ooK4uc
Subscribe to our HiveMQ channel to get video updates. Hit the subscribe button above or subscribe to our newsletter (https://bit.ly/3os4nqr) to keep up to date on the latest MQTT news.
👉 We're looking forward to seeing you next week for MQTT Essentials part 10 - Last Will & Testament. • MQTT Last Will and Testament | MQTT Essent...
#MQTT #MQTTEssentials #MQTTMonday #IoT