Is message order preserved in MQTT messages?

后端 未结 1 987
花落未央
花落未央 2020-12-14 07:17

I wonder if the message sent order is preserved. That is, when a publisher sends a sequence of messages, is each subscriber guaranteed to receive the same sequence as the pu

1条回答
  •  时光说笑
    2020-12-14 07:34

    A summary of the message ordering capabilities in MQTT 3.1.1 can be found in the specification itself here.

    In summary:

    • no guarantees are made about the relative ordering of messages published with different QoS values. (for example, QoS 0 can over take QoS 2 for example as it involves a single packet rather than the 4 packets of the latter).
    • QoS 0 messages will be delivered in order (albeit messages may get lost)
    • QoS 2 messages will be delivered in order
    • QoS 1 allows for message duplicates - it is possible a duplicate will arrive after the first instance of the next message that was published.

    QoS 1 ordering can be guaranteed if the client/broker only allow a single message inflight at any time.

    0 讨论(0)
提交回复
热议问题