0
votes

I am working on a communication module in which server sent data to mqtt and another client module recieves the message from mqtt. Here I need an acknowledgement from mqtt nodejs client after recieving a message so that i can delete the message from server queue.

I am using nodejs mqtt client package(https://www.npmjs.com/package/mqtt#publish). Is there a default acknowledgement function for mqtt package.

client.handleMessage = (packet: any, callback) => {
  console.log(packet);
};

In the above code inside handle message is there a callback function to return a default acknowledgement to server.

1

1 Answers

1
votes

No.

There is no end to end delivery notification in MQTT.

If you want to notify the publisher that a* subscriber has handled a message you will need to handle all of that yourself by publishing another message.

As on MQTT v5 there is a message header flag to indicate that a message is a direct response to a previous message, but you still have to publish this yourself.

*it is important to remember that there and be anything from 0 to many subscribers to a given topic