Mqtt主题设计

protocol_prefix / src_id / dest_id / message_id / extra_properties

  • protocol_prefix is used to differentiate between different protocols/ application that can be used at the same time

  • src_id is the ID of the mqtt client that publishes the message. It is expected to be the same as “client ID” used to connect to MQTT broker. It allows quick ACL control to check whether the client is
    allowed to publish specific topic.

  • dest_id is client ID of the “destination” unit, i.e. to whom the message is intended. Also allows quick ACL control on the broker of whether client is allowed to subscribe to a particular topic. There can be reserved “destination” strings to specify that the message is broadcasted to anyone who is interested. For example all.

  • message_id is actual ID of the message within used protocol. I usually use numeric value (as string of course), because the IOT or other embedded system that is connected to MQTT broker can have other I/O links and I would like to use the same protocol (but with different transport framing) to control the device using these other I/O links. I usually use numeric message IDs in such communication links.

  • extra_properties is an optional subtopic which can be used to communicate other MQTT specific extra information (comma separated key=value pairs for example). Good example would be reporting timestamp of the message when it was actually sent by the client. In case of “retained” messages it can help to identify the relevance of the received message. With MQTTv5 protocol that is expected to arrive soon, the need for this subtopic may disappear because there will be other way to communicate extra properties.

  • 协议前缀用于区分可以同时使用的不同协议/应用程序

  • 源id 是发布消息的mqtt客户机的ID。它是 期望与用于连接到MQTT的“客户端ID”相同 代理。通过快速ACL控制来检查客户端是否存在 允许发布特定的主题。

  • 目标id是“目标”单元的客户端ID,即消息要发送给谁。还允许在代理上快速控制客户端是否被允许订阅特定的ACL的话题。可以使用保留的“destination”字符串来指定这条信息被广播给任何感兴趣的人。为所有示例。

  • 消息id是使用的协议中消息的实际id。我 通常使用数字值(当然作为字符串),因为物联网或 连接到MQTT代理的其他嵌入式系统可以具有其他 I/O链接和我想使用相同的协议(但与 不同的传输框架)来控制设备使用这些其他 I /O链接。我通常在这种通信中使用数字消息id 链接。

  • 额外属性是一个可选的子主题,可以用于 通信其他MQTT特定的额外信息(逗号分隔 例如键=值对)。报道就是一个很好的例子 客户机实际发送消息时的时间戳。在 “保留”消息的情况,它可以帮助识别相关性 接收到的消息。使用预期到达的MQTTv5协议很快,对这个子话题的需求可能会消失,因为将来会有 另一种传达额外属性的方式。.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值