hivemq-mqtt-client icon indicating copy to clipboard operation
hivemq-mqtt-client copied to clipboard

FR: File persistence of pending to be published messages

Open KeithLaiKB opened this issue 3 years ago • 3 comments
trafficstars

case

step1: publisher send 1,2,3,4,5 (total 5 messages) subscriber received 1,2,3,4,5 (total 5 messages)

step2: and then I close the program of the broker and wait for a while.

step3: then publisher keep going to send 6,7,8 (total 3 messages)

step4: shutdown the publisher program

step5: restart the broker, and subscriber auto reconnect to the broker

step6: restart the publisher and send 13, 14, 15 (total 3 messages)

howerver, subscriber couldn't receive the 6,7,8 (total 3 messages) in step3

Is there a MqttDefaultFilePersistence feature? it seems like it is just in-memory persistent.

KeithLaiKB avatar Feb 10 '22 10:02 KeithLaiKB

I think this is not a problem. mqtt only have retained message that store only the last message that publish to a topic that no one subscribe, this is the protocol that it designed to be. You can refer to this article

So on your step 3, you publish to a topic that currently no none subscribe(if you mean to), so message will be discard directly(only if you set the message to retained, but only last one)

PS:On your step2, you mean close publisher or broker?

cxshun avatar Feb 11 '22 06:02 cxshun

I think this is not a problem. mqtt only have retained message that store only the last message that publish to a topic that no one subscribe, this is the protocol that it designed to be. You can refer to this article

So on your step 3, you publish to a topic that currently no none subscribe(if you mean to), so message will be discard directly(only if you set the message to retained, but only last one)

PS:On your step2, you mean close publisher or broker?

yes in step2, just close the broker, and wait for a while. well, as for paho_mqtt case:

It provides you with MqttDefaultFilePersistence or MemoryPersistence.

When you choose to use MqttDefaultFilePersistence. in step3 because now the broker is off, 6,7,8 (total 3 messages)could not send to the broker, but the publisher could save the 6,7,8 (total 3 messages) in a file, when the broker restart, and restart the publisher, it could also send the 6,7,8 (total 3 messages) from the file to the broker.

I think this feature is really useful and provides the program with steady.

As for retained message, it seems that it just could send the new message 8 in 6,7,8 (total 3 messages), it could not meet the need of this requirement.

KeithLaiKB avatar Feb 11 '22 08:02 KeithLaiKB

Hi all - I've marked this issue as a feature request for file persistence. Thanks for pointing this out!

pglombardo avatar Mar 07 '23 15:03 pglombardo