0

想象一下,我有 3 个发布者,A、B 和 C。

  • 发布者 A 向 SOME/TOPIC 发送消息 FOO、BAZ、SOMETHING
  • 发布者 B 向 SOME/TOPIC 发送消息 FOO, SOMETHING
  • 发布者 C 不向 SOME/TOPIC 发送消息

SOME/TOPIC 的订阅者会收到哪些消息?

我想知道这一点的动机是发布者 A、B 和 C 正在从不可靠的数据源中提取这些消息,他们可能会错过一些消息,因此我有多个发布者发布到同一个主题作为冗余形式。这是个好主意还是坏主意?

4

1 回答 1

1

Subscribers would see all the messages from A & B, what order they are delivered to the subscribers would depend on what order they arrived at the broker (which is going to come down to the order they arrive over the network normally) and to some extent how the broker is implemented.

The MQTT broker spec make no mention of how to handle multiple identical messages and as such would treat them as any other message, unless you choose to create a custom broker to do differently.

If this is a good idea or not we can't answer, as we have no idea of the consequences of the subscriber(s) receiving multiple identical messages (e.g. multiple FOO & SOMETHING messages) because the message when delivered will not contain any information about which client published it (unless you choose to encode that in the payload).

于 2020-07-15T07:43:06.970 回答