I have a Situation once message received from MQTT Broker, During processing the data , assume that DB is down and not completed the task. In that particular situation Data that received has to sent back to Broker that my task is not completed I mean rollback.
How to achieve this and how to tell broker that during processing the data some exception came and you need to send the data again.
can some one hep on this?
It can be done, but only with certain MQTT client libraries that allow you to take full control of the QOS handshake process.
Assuming a client has subscribed at QOS 1 or 2 to a topic it can then chose to hold of sending the PUBACK or PUBREC packet back to the broker. It can hold off completing the QOS handshake until the message has been fully processed. If the processing fails and the full handshake is not completed then the broker will try to redeliver the message again to the client so the client should go offline in the case of a failure so the broke will queue the message.
When the backend (datastore) comes back online the client can reconnect to the broker and the queued messages will be redelivered.