保留消息定义

  如果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. How to use VideoToolbox to decompress H.264 video stream

    来源:http://stackoverflow.com/questions/29525000/how-to-use-videotoolbox-to-decompress-h-264-video-str ...

  2. idea svn 文件还原到指定版本

    使用svn经常会遇见,由于自己或者其他同事的提交(或者误操作),把原本正确代码或文件覆盖掉了,现在就得需要恢复到之前指定的某个版本. 先打开指定的文件,然后右上角点击时间的按钮: 这比会出现以前的许多 ...

  3. 小程序插件集成functional-page-navigator真机调试报错

    小程序集成插件 插件里面有functional-page-navigator标签 一."小程序开发版已过期,请重新扫码连接" 真机在调用插件的时候报错 "小程序开发版已过 ...

  4. windows 给mysql安装innodb引擎

    1.启用InnoDB    打开my.ini文件,找到[skip-innodb],在前面加# 2.更改数据库默认引擎为InnoDB    打开my.ini文件,更改[default-storage-e ...

  5. 谷歌学术出现We're sorry解决办法

    出现这个的原因应该是同ip段的或者就是这个ip曾经是个google的黑名单ip,因为恶意爬取谷歌学术了.解决办法就是申请Hurricane Electric Free IPv6 Tunnel Brok ...

  6. 微信小程序中的事件

    事件 说明 bindtap bindload 当图片载入完毕时触发,event.detail = {height, width} bind事件绑定不会阻止冒泡事件向上冒泡,catch事件绑定可以阻止冒 ...

  7. 06-numpy-笔记-shape

    shape 是返回 np.mat 的形状的. 1. 作为 mat 的成员变量,a.shape 2. 作为 np 的成员函数,np.shape >>> import numpy as ...

  8. python windows下获取路径时有中文处理

    在windows中用os,path.abspath(__file__)时有中文路径时,默认是转成非unicode格式 这会导致,在其它模块使用该路径时,会报 utf8' codec can't dec ...

  9. CanvasRenderingContext2D.drawImage()无效,not working

    我的技术框架:react,如若不采用堵塞方式,即, const myimg = await loadImage(icon28) ctx.drawImage(myimg,0,0, 100, 100)   ...

  10. mysql Navicat通过代理链接数据库

    1.做完host 账号 密码(数据库服务器)配置之后,选择ssh 2.配置代理服务器ip的登录的账号密码.(代理服务器必须可以连你的Navicat客户端和数据库服务器,不然怎么做代理.) 3.可以直接 ...