Mqtt精髓系列之发布订阅
2017-11-30 10:44
369 查看
翻译:https://www.hivemq.com/blog/mqtt-essentials-part-4-mqtt-publish-subscribe-unsubscribe
客户端发布到Broker时,由客户端设置消息ID,Broker投递到客户端时由Broker设置消息ID;
A SUBSCRIBE message can contain an arbitrary number of subscriptions for a client. Each subscription is a pair of a topic topic and QoS level. The topic in the subscribe message can also contain wildcards, which makes it possible to subscribe to certain topic patterns. If there are overlapping subscriptions for one client, the highest QoS level for that topic wins and will be used by the broker for delivering the message.
发布Publish
QoS
客户端发布到Broker的消息Qos;Retain-Flag
当前发布的消息是否为保留消息;消息ID Packet Identifier
消息ID只在Qos>0时使用,且范围为0~65535,尽可能减少了消息头;(协议涉设计者认为消息流不可能出现有65535条消息没得到确认,一旦确认消息ID即可重复使用)客户端发布到Broker时,由客户端设置消息ID,Broker投递到客户端时由Broker设置消息ID;
DUP flag
消息是否重发的标识订阅Subscribe
客户端为了接受到订阅消息,必须发送订阅消息SUBSCRIBE,进行动态Topic订阅,SUBSCRIBE消息组成如下图所示:List of Subscriptions
订阅关系由Topic+Qos组成,Subscribe中可以包含任意的订阅关系。当订阅关系出现重叠时,选取高level的Qos。A SUBSCRIBE message can contain an arbitrary number of subscriptions for a client. Each subscription is a pair of a topic topic and QoS level. The topic in the subscribe message can also contain wildcards, which makes it possible to subscribe to certain topic patterns. If there are overlapping subscriptions for one client, the highest QoS level for that topic wins and will be used by the broker for delivering the message.
相关文章推荐
- MQTT的学习研究(十一) IBM MQTT 简单发布订阅实例
- MQ系列-ActiveMQ发布/订阅模式
- MQTT的学习研究(十二) MQTT moquette 的 Future API 消息发布订阅的实现
- MQTT基础——Part 2. 发布/订阅模式
- Mqtt精髓系列之服务质量Qos
- Mqtt精髓系列之保留消息Retained Messages
- WCF 4.0 进阶系列 – 第十六章 使用回调合约发布和订阅事件(第一部分)
- MQTT 消息 发布 订阅
- Redis系列(三)—— 订阅/发布
- MQTT的学习研究(十四) MQTT moquette 的 Callback API 消息发布订阅的实现
- MQTT的学习研究(十一) IBM MQTT 简单发布订阅实例
- MQTT的学习研究(十三) IBM MQTTV3 简单发布订阅实例
- MQTT的学习研究(十二) MQTT moquette 的 Future API 消息发布订阅的实现
- Redis入门系列之队列和发布订阅模式
- MQTT的学习研究(十三) IBM MQTTV3 简单发布订阅实例
- 51系列小型操作系统精髓 简单实现9 C语言版优化后发布(有图)
- Redis系列(三)-Redis发布订阅及客户端编程
- JavaScript设计模式系列05_观察者模式(发布订阅)写的数据联动(类似于vue的数据绑定)
- WCF 4.0 进阶系列 – 第十六章 使用回调合约发布和订阅事件(第二部分)
- 从零开始学_JavaScript_系列(九)——dojo(2)(AJAX、时间控件、鼠标事件、样式修改、事件移除、消息发布订阅)