简体   繁体   English

ActiveMQ Artemis 上的 MQTT 侦听器 - 如何确保订阅者使用所有消息(不仅仅是最新消息)

[英]MQTT Listener on ActiveMQ Artemis - how to ensure all messages (not just latest) are consumed by subscriber

I would like to use use ActiveMQ Artemis as an MQTT broker to ensure that all subscribers to a MQTT topic will receive the MQTT messages, not just the latest one.我想使用 ActiveMQ Artemis 作为 MQTT 代理,以确保 MQTT 主题的所有订阅者都将收到 MQTT 消息,而不仅仅是最新消息。

For example, an MQTT subscriber crashes and is unable to receive messages for a while.例如,MQTT 订阅者宕机,一段时间无法接收消息。 When the subscriber comes back online, it should receive all the messages that had been published to a topic.当订阅者重新上线时,它应该会收到已发布到主题的所有消息。

From this post , which give the following graphic:这篇文章中,它给出了以下图形:

MQTT 保留消息

it appears that by setting the QOS to 1 and the retain to true, all messages to a topic will be saved until they are consumed by the subscribers.似乎通过将 QOS 设置为 1 并将保留设置为 true,所有发送到主题的消息都将被保存,直到它们被订阅者使用。 Is this the case?是这样吗?

If necessary, I could add a UUID to the topic.如有必要,我可以在主题中添加一个 UUID。 For example, publish to topic mytopic/13234141431432 and subscribe to mytopic/# .例如,发布到主题mytopic/13234141431432并订阅mytopic/# However, the first option is preferable just for simplicity sake.但是,为了简单起见,第一个选项更可取。

Retained is different to QOS delivery requirements.保留不同于QOS交付要求。

Setting the retained flag will just tell the broker to hold on to the last message on a given topic with the retained flag set and always deliver that message to any new subscribers (including returning clients that have been offline).设置保留标志只会告诉代理保留给定主题上设置了保留标志的最后一条消息,并始终将该消息传递给任何新订阅者(包括已经离线的返回客户端)。 Retained is how to ensure a client always gets the current state/last state of a topic, not any of the preceding messages. Retained 是如何确保客户端始终获取主题的当前状态/最后状态,而不是任何先前的消息。 (Also the retained message may be delivered before any queued messages) (保留的消息也可以在任何排队的消息之前传递)

If you want to ensure that all missed messages are delivered to a client that has been offline you must publish and subscribe at QOS 1 or 2 and ensure that the Clean Session flag is false when reconnecting.如果要确保将所有错过的消息传递给已离线的客户端,则必须以 QOS 1 或 2 发布和订阅,并确保重新连接时 Clean Session 标志为 false。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ActiveMQ Artemis如何在没有取消订阅的情况下监听进程终止时判断MQTT订阅者何时取消订阅 - How does ActiveMQ Artemis determine when an MQTT subscriber is unsubscribed when the listening process terminates without unsubsribing ActiveMQ Artemis和MQTT桥接 - ActiveMQ Artemis and MQTT bridging 如何在ActiveMQ Artemis中为基于keystore和truststore的MQTT协议启用SSL - How to enable SSL in ActiveMQ Artemis for MQTT protocol based on keystore and truststore 如何处理 MQTT 订阅者中的部分消息? - How to handle partial messages in MQTT subscriber? MQTT订户错过的消息 - MQTT subscriber missed messages RabbitMQ&MQTT:如何向第三方提醒未使用的消息? - RabbitMQ & MQTT : how to alert a third party of non consumed messages? 即使现在没有订阅者,如何告诉MQTT保留消息? - How to tell MQTT to keep messages even if there is no subscriber right now? 如何使用MQTT(Paho)+ activeMQ接收消息的正确方法? - How is the correct way to receive messages using MQTT (paho) + activeMQ? Apache ActiveMQ Artemis MQTT 代理拒绝连接 - 可能的连接限制 - Apache ActiveMQ Artemis MQTT broker refuses connections - possible connection limit 在 ActiveMQ Artemis 中设置和配置 Apache Camel 用于 MQTT 处理 - Setup and configure Apache Camel in ActiveMQ Artemis for MQTT handling
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM