保留消息定义

  如果PUBLISH消息的RETAIN标记位被设置为1,则称该消息为“保留消息”;

  Broker会存储每个Topic的最后一条保留消息及其Qos,当订阅该Topic的客户端上线后,Broker需要将该消息投递给它。

A retained message is a normal MQTT message with the retained flag set to true. The broker will store the last retained message and the corresponding QoS for that topic Each client that subscribes to a topic pattern, which matches the topic of the retained message, will receive the message immediately after subscribing. For each topic only one retained message will be stored by the broker.

保留消息作用

  可以让新订阅的客户端得到发布方的最新的状态值,而不必要等待发送。

A retained message makes sense, when newly connected subscribers should receive messages immediately and shouldn’t have to wait until a publishing client sends the next message. This is extremely helpful when for status updates of components or devices on individual topics. For example the status of device1 is on the topic myhome/devices/device1/status, a new subscriber to the topic will get the status (online/offline) of the device immediately after subscribing when retained messages are used. The same is true for clients, which send data in intervals, temperature, GPS coordinates and other data. Without retained messages new subscribers are kept in the dark between publish intervals. So using retained messages helps to provide the last good value to a connecting client immediately.

保留消息的删除

  1. 方式1:发送空消息体的保留消息;
  2. 方式2:发送最新的保留消息覆盖之前的(推荐);

MQTT --- Retained Message的更多相关文章

  1. EMQ学习笔记---Clean Session和Retained Message

    MQTT会话(Clean Session)MQTT客户端向服务器发起CONNECT请求时,可以通过’Clean Session’标志设置会话.‘Clean Session’设置为0,表示创建一个持久会 ...

  2. MQTT 单个订阅消息量过大处理

    The missing piece between MQTT and a SQL database in a M2M landscape Message Queue Telemetry Transpo ...

  3. Tsung MQTT协议简介及MQTT xml文档配置介绍

    MQTT协议简介及MQTT xml文档配置介绍 by:授客 QQ:1033553122 1. MQTT协议介绍 MQTT(Message Queuing Telemetry Transport,消息队 ...

  4. MQTT 3.1.1,值得升级的6个新特性

    前言 以前看英文文章或资料,看完之后,摘要或者忘记.这一次选择感兴趣的MQTT 3.1.1介绍文章资料,引文见文末,作为练手:非完全翻译,去除掉一些广告性描述,若侵权,请告知. 在沉寂了四年之后,QT ...

  5. Android Apollo MQTT入门

    一.Apache Apollo服务器其实是一个消息中转站 下载地址 http://activemq.apache.org/apollo/download.html 服务搭建方式,参看博客Android ...

  6. mqtt使用二(集成到java代码中)

    1.我采用的是springboot,首先pom文件中添加mqtt需要用到的依赖 <dependency> <groupId>org.springframework.boot&l ...

  7. 物联网架构成长之路(32)-SpringBoot集成MQTT客户端

    一.前言 这里虽然是说MQTT客户端.其实对于服务器来说,这里的一个具有超级权限的MQTT客户端,就可以做很多事情.比如手机APP或者网页或者第三方服务需要发送数据到设备,但是这些又不是设备,又不能让 ...

  8. MQTT协议及EMQ应用

    MQTT是基于TCP/IP协议栈构建的异步通信消息协议,是一种轻量级的发布/订阅信息传输协议.MQTT在时间和空间上,将消息发送者与接受者分离,可以在不可靠的网络环境中进行扩展.适用于设备硬件存储空间 ...

  9. spring boot 集成mqtt

    1.pom文件中添加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifact ...

随机推荐

  1. ansible自动化运维03

    ansible自动化运维常用模块 常用模块实现的功能:安装软件包:修改配置文件:创建程序用户组:创建目录,并修改所属和权限:挂载:启动服务:测试. command模块: shell模块: 注意:com ...

  2. Python实现感知器的逻辑电路(与门、与非门、或门、异或门)

    在神经网络入门回顾(感知器.多层感知器)中整理了关于感知器和多层感知器的理论,这里实现关于与门.与非门.或门.异或门的代码,以便对感知器有更好的感觉. 此外,我们使用 pytest 框架进行测试. p ...

  3. 遍历php的_SERVER数组键值信息

    $_SERVER 是一个包含了诸如头信息(header).路径(path).以及脚本位置(script locations)等等信息的数组.这个数组中的项目由 Web 服务器创建.不能保证每个服务器都 ...

  4. 使用ftp搭建yum仓库

    此次操作在VMware Workstation虚拟机的CentOS7.5下进行 这里使用两台Linux主机,下表是它们所使用的操作系统以及IP地址. 两台Linux主机所使用的操作系统以及IP地址 操 ...

  5. 第12节-BLE协议HCI层的数据格式

    学习资料: 1. 蓝牙协议core_v5.0.pdf <Vol 2: Core System Package [BR/EDR Controller volume]>的“Part E: Ho ...

  6. dedecms去掉标题长度限制

    dedecms文章标题默认显示字数为60字节(30个汉字),如果想要显示更多要如何操作呢?两步解决问题,随ytkah一起来看看吧.1.后台找到“系统设置-系统基本参数-其他其他选项”(如下图)这时你可 ...

  7. go处理XML

    XML 数据格式 对于如下的XML: <Person> <FirstName>Laura</FirstName> <LastName>Lynn</ ...

  8. this指向问题(改变它的指向)

    这个问题倒不是面向对象的,而是今天遇到js面向对象的时候一个例子的时候突然遇到了,call()方法,然后自己突然发现竟然忘记了,查了之后整理如下: xxx.call((对象名),参数a,参数b) xx ...

  9. LeetCode 568. Maximum Vacation Days

    原题链接在这里:https://leetcode.com/problems/maximum-vacation-days/ 题目: LeetCode wants to give one of its b ...

  10. Chrome DevTools的使用

    一.Chrome DevTools 简介 Chrome 开发者工具是一套内置于Google Chrome中的Web开发和调试工具,可用来对网站进行迭代.调试和分析 手册:Chrome 开发者工具中文手 ...