Mqtt精髓系列之发布订阅

翻译:https://www.hivemq.com/blog/mqtt-essentials-part-4-mqtt-publish-subscribe-unsubscribe

发布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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值