I am just getting started with mqtt , I have an application which sends out data asynchronously.I am using
the asynchronous mqtt paho client for this. I have set qos as 2 and clean session is true. The device in which
I am running my client application is a very limited device which gets disconnected from the data connection
most of the times due to intermittent network outages.So I am testing the reliability of the device to send data once
the connection resumes without ANY data loss.
I have handled connection lost aync callback and it tries to reconnect till it succeeds.
Another thread runs always and keep publishing data , the thread do not care whether the connection
is ON or not , it just calls the publish method of my mqtt instance.
Here are my connection options.
library used = mqtt paho client for java ( mqtt-client-0.4.0.jar )
clean session = true
qos = 2
keepalive = 60
My problem is Situation B.
Situation A ( Success ) ( A thread is relentessly publishing data to my async mqtt client instance , it do not care whether the client is connected or not )
1) Good connectivity , published data is delivered , all good :)
2) NO data connectivity , connect lost callback is not called yet , because the keep alive limit not reached.
3) Thread is still pushing data to the mqtt client instance publish method.
4) I get back connectivity , before keep alive limit , all the pending messages are delivered ! all good.
Situation B ( Failure ) ( A thread is relentessly publishing data to my async mqtt client instance , it do not care whether the client is connected or not )
1) Good connectivity , published data is delivered , all good :)
2) NO data connectivity , connect lost callback is not called yet , because the keep alive limit not reached.
3) Thread is still pushing data to the mqtt client instance publish method.
4) Still no connectivity , keep alive reached. connection lost is called.
5) Thread is still pushing data to the mqtt client instance publish method , only to get exception that "client is not connected"
6) I get back connectivity , the messages after data connectivity loss and before "connection lost" is delivered , good !
Problem --->
7) But the messages after "connection lost" till the connection regained are not anywhere to be seen.Its not delivered.
Is this the way the mqtt spec says , or is there a technical problem. What I understood from the spec is Qos = 2 ensures data delivery , no matter what , even after the connection is lost , all the pending messages is
supposed to be delivered once the connection comes back.
I would really appreciate any help on this. Situation B , scenario 7.