Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » Is MqttClientPersistence ever needed for subscriber ?
Is MqttClientPersistence ever needed for subscriber ? [message #1705434] Sat, 15 August 2015 10:25 Go to next message
Kiran Pradeep is currently offline Kiran PradeepFriend
Messages: 4
Registered: August 2015
Junior Member
The java doc page for MqttClientPersistance, reads "Represents a persistent data store, used to store outbound and inbound messages while they are in flight". Why is it needed for an inbound message or more specifically why is MqttClientPersistence needed for MQTT subscriber ?

For a MQTT publisher, we need to wait for the PUBACK packet and so usage of MqttClientPersistence is clear.

Assuming, my client is always an MQTT subscriber, independent of QOS, can I always instantiate it as below ?
//instantiate subscriber client with null persistance 
MqttClient subcriberClient = new MqttClient( uri, cientId, null );
Re: Is MqttClientPersistence ever needed for subscriber ? [message #1705548 is a reply to message #1705434] Mon, 17 August 2015 12:56 Go to previous messageGo to next message
Benjamin Cabé is currently offline Benjamin CabéFriend
Messages: 201
Registered: July 2009
Location: Toulouse, France
Senior Member

When a client receives a QoS 1 message, it also need to answer with a PUBACK. If you lose Internet connectivity just after receiving a qos1 PUBLISH, the store can be used to later know that there's something that still needs to be PUBACK'd.

Similarly, QoS 2 requires some acks to be sent, and you want the store to make sure you do not incorrectly make the broker assume that something hasn't been received while it actually has.

HTH!


Re: Is MqttClientPersistence ever needed for subscriber ? [message #1705559 is a reply to message #1705548] Mon, 17 August 2015 13:32 Go to previous messageGo to next message
Ian Craggs is currently offline Ian CraggsFriend
Messages: 83
Registered: March 2013
Member
Considerations:

1) persistence is only needed for QoS 1 and 2 messages

2) if the client connects clean session=true, then persistence does not matter because all state is deleted if/when the connection is broken

3) disk persistence is only needed if a) you connect clean session=false and b) if you want to be able to delete the client object (by stopping the application for instance) and restart the application in the same state by recreating the client object. In that case, the client object state information is read from disk.

It doesn't matter whether you are publishing or subscribing, these hold true both ways.
icon14.gif  Re: Is MqttClientPersistence ever needed for subscriber ? [message #1705632 is a reply to message #1705434] Tue, 18 August 2015 05:02 Go to previous messageGo to next message
Kiran Pradeep is currently offline Kiran PradeepFriend
Messages: 4
Registered: August 2015
Junior Member
Thanks for both replies. It helps.

A probable related query - please tell if this has to go in a separate post.
Does the clean_session flag matter for a mqtt publisher? In a publisher, the only time, I should set clean_session to false will be to receive the acknowledgments like PUBACK when a connection gets broken just after publishing a message ?
icon14.gif  Re: Is MqttClientPersistence ever needed for subscriber ? [message #1705707 is a reply to message #1705559] Tue, 18 August 2015 13:03 Go to previous message
Kiran Pradeep is currently offline Kiran PradeepFriend
Messages: 4
Registered: August 2015
Junior Member
Thanks for the additional point on disk persistence. I was wondering why it was needed.
Previous Topic:Paho MQQTT Client get an java.util.concurrent.TimeoutException
Next Topic:MQTTWS31.js reconnect bug
Goto Forum:
  


Current Time: Fri Apr 19 04:18:20 GMT 2024

Powered by FUDForum. Page generated in 0.02208 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top