追赶错过的消息 [英] Catch-up missed messages
问题描述
据我了解,当消息发布到某个主题时,只有当前订阅该主题的客户端才能接收到该消息.如果客户端在消息发布后出现,它将不会收到该消息.
As far as my understanding goes, when a message is published to a topic, it is received by only the clients currently subscribed to that topic. If a client turns up after the message is published, it won't receive that message.
假设客户端暂时断开连接,有什么方法可以帮助客户端赶上再次连接时丢失的消息?
Suppose a client is disconnected momentarily, is there a way to help the client catch-up with the messages missed when it is connected again?
谢谢
推荐答案
如果客户端订阅了主题,则与代理的连接将被断开,客户端将需要重新连接.
If a client subscribes to a topic then the connection to the broker is dropped, the client will need to reconnect.
只要客户端在连接上设置cleanSession = false标志并重新订阅相同的主题,代理就应重播所有丢失的消息.
As long as client sets the cleanSession=false flag on the connection and resubscribes to the same topics the broker should replay any missed messages.
有关持久订阅的更详细说明,请参见:
A more detailed description of durable subscriptions can be found here:
http://www.hivemq.com /mqtt-essentials-part-7-persistent-session-queuing-messages/
在这里:
http://www.thingsprime.com/?p=2897
这篇关于追赶错过的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!