gpt4 book ai didi

mqtt - 简化情况下可以保证mqtt msg传递顺序吗?

转载 作者:行者123 更新时间:2023-12-05 04:13:19 35 4
gpt4 key购买 nike

如果只有一个代理、一个发布者、一个主题和干净的 session ,在这种简化的情况下,

能否保证订阅者端的消息发送顺序与发布者端的发送顺序相同?会不会受到QoS的影响?

最佳答案

4.6来自 MQTT 3.1.1 spec涵盖消息排序:

4.6 Message ordering

A Client MUST follow these rules when implementing the protocol flows defined elsewhere in this chapter:

  • When it re-sends any PUBLISH packets, it MUST re-send them in the order in which the original PUBLISH packets were sent (this applies to QoS 1 and QoS 2 messages) [MQTT-4.6.0-1]
  • It MUST send PUBACK packets in the order in which the corresponding PUBLISH packets were received (QoS 1 messages) [MQTT-4.6.0-2]
  • It MUST send PUBREC packets in the order in which the corresponding PUBLISH packets were received (QoS 2 messages) [MQTT-4.6.0-3] It MUST send PUBREL packets in the order in which the corresponding PUBREC packets were received (QoS 2 messages) [MQTT-4.6.0-4]

A Server MUST by default treat each Topic as an "Ordered Topic". It MAY provide an administrative or other mechanism to allow one or more Topics to be treated as an "Unordered Topic" [MQTT-4.6.0-5].

When a Server processes a message that has been published to an Ordered Topic, it MUST follow the rules listed above when delivering messages to each of its subscribers. In addition it MUST send PUBLISH packets to consumers (for the same Topic and QoS) in the order that they were received from any given Client [MQTT-4.6.0-6].

阅读后我会得出结论,消息通常会按顺序发送(除非代理特别设置为使用无序主题),但如果高 QOS 消息未被正确确认,它可能会被重新发送,这可能导致它被重新传送乱序。

关于mqtt - 简化情况下可以保证mqtt msg传递顺序吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38094476/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com