I'm trying to get some peculiar form of QOS from MQTT on intermittent connections, and I wonder whether my use case can be implemented cleanly with the protocol. I need to connect a client to a broker over an unreliable and low-bandwidth link.
When the client reconnects, I want it to catch up on what happened when it was off, so I guess I need persistent sessions.
But if the payload under a given topic changes a dozen times while the client was off, I want to receive only the latest version, not the 11 obsolete ones.
If the payload under a given topic didn't change while the client was disconnected, I don't want it to be resend upon reconnexion.
My understanding is that a QOS1 message will be delivered to a persistent session as soon as it reconnects, but the client will also receive the 11 obsolete messages, in addition to the only latest version it needs.
I also understand that a QOS0 retained message will only be sent to a clean session, not to a reconnecting persistent session which may already have received a message for that topic.
If I use clean sessions with QOS0 retained messages, the client will only receive the latest version of each topic when connecting, but the broker will also resend the topics whose payload didn't change while the connection was off, which is not acceptable bandwidth-wise.