Message acknowledegement

I need to get the acknowledgement from the receiver, How I can achieve this in HiveMQ.
I am trying to get the acknowledgement using ReponseTopic and CorrelatioData properties but I am not getting this two property data. I am using mqttnet library to achieve this.
Please asist.

Hi @girishgsv,

where do you need to get the acknowledgement exactly?
Also which ack do you mean:
a) when you publish a message from a client to HiveMQ
b) when HiveMQ sends the message to the subscriber?

Greetings,
Michael

I need acknowledgement from Subscriber to Publisher.

So does that mean:

  • subscriber X gets a message from HiveMQ
  • subscriber X sends acknowledgement to the publisher Y that sent the message to HiveMQ (that was sent so subscriber X)?

I fear this is not possible out of the box because the message flow from, Publisher → HiveMQ and HiveMQ → Subscriber are decoupled (see section “The publish/subscribe pattern” here).

Before we try to find a way forward I need to understand your problem more clearly.

Publisher Y publishes the message and subscriber X receives the message.
Once subscriber X receives the message successfully then subscriber X should send the acknowledgement to publisher Y (that is has received the message).
I found there is article for End to End Acknowledgement, see below link,

Well this is not possible out of the box.
The publisher gets an acknowledgment from the broker the moment the broker stored the publish message in it’s system. At this time the message was most likely not sent to the subscriber yet.

The only thing you can do is to work, as you already mentioned, with the “ReponseTopic” (RT).
The publisher adds the RT to his publish message, the broker forwards the RT with the publish message to the subscriber. Now the subscriber can extract the RT and send his own publish message, which acts as a ACK message, to the publisher.

As response topic is an MQTT 5 feature make sure you use the correct client from the mqttnet library, see: The "ResponseTopic" property of MqttApplicationMessage is not transferred · Issue #808 · dotnet/MQTTnet · GitHub

EDIT: Yes, exactly like in the code snippet of the blog post you linked

1 Like

I got your point. Thanks for clarification.

We have below requirement, If you can assist how to achieve this then it will be helpful,
=> Once subscriber receive the message, it does some processing on the message, once processing is done then publisher should know the message is processed at subscriber end. and it should be relayed to correct publisher.

Hey @girishgsv ,

In order for you to utilise ReponseTopic feature of MQTT v5, you need to make sure that your client library that you use supports MQTT v5 and / or this feature. For example, the HiveMQ MQTT Client library.
Your client1 should implement the logic:
once I receive a message on Topic1, I get the Response Topic from the message, then I do some processing, once processing is done, I publish my confirmation message to the Response Topic.
You client2 should then subscribe itself to the Response Topic and then start publishing to the Topic1. Once the client1 responds the client2 will receive message on the Response Topic.

Please note that both clients should support MQTT v5 in order to utilise the Response Topic functionality.

For more info on MQTT v5 Response topic feature: Request - Response Pattern - MQTT 5 Essentials Part 9
For a working example of Request-Response pattern: hivemq-mqtt-client/RequestResponse.java at master · hivemq/hivemq-mqtt-client · GitHub

I hope this helps :slight_smile:
Regards,
Dasha from HiveMQ team

Thanks for your reply, but client1 and client2 example is confusing. Could you please elaborate more.
Thanks in advance.

ReponseTopic and CorrelatioData are MQTT v5 features. In order to utilise ReponseTopic and CorrelatioData, you need to make sure that your client and broker support MQTT v5.

I quickly searched “ResponseTopic” in this MQTTnet library and found an example of a client sending a response to the responseTopic here: https://github.com/dotnet/MQTTnet/blob/d98129481a0bb39572cb5f0a583655f828bb621c/Source/MQTTnet.Extensions.Rpc/SampleCCode.c

Your client should implement a similar callback function as in this example.

I hope this helps,
Dasha from HiveMQ team

Thanks for your reply.
Can we use MQTTnet library in .net framework? Do you have any documentation about how to use .MQTTnet library in .net framework

Yes @girishgsv , you can, please refer yourself to theses examples: MQTTnet/Client_Connection_Samples.cs at master · dotnet/MQTTnet · GitHub

I hope this helps
Dasha from HiveMQ team

From your referenced link, I downloaded the project and it uses MQTTnet project.
In your previous comment it is mentioned that RT is supported in MQTT v5 and you have given reference of “HiveMQ MQTT Client library”. I wanted to ask whether HIveMQ provide client library for .net that supports MQTT v5.
We are using MQTTnet library available on nuget, but this library still have v3.1.1, 5.0 is still under pre-release.
Please assist how to go ahead.

Hi @girishgsv

HiveMQ is providing Java library GitHub - hivemq/hivemq-mqtt-client: HiveMQ MQTT Client is an MQTT 5.0 and MQTT 3.1.1 compatible and feature-rich high-performance Java client library with different API flavours and backpressure support
HiveMQ is not providing .net library.

I hope that answers your questions,
Dasha from HiveMQ Team

Thanks for information. can I use the Java library in .net?

No, you can’t.

In case if you are referring to this lib, a quick search in its code indicates that this lib supports ResponseTopic feature.

If you have further questions about HiveMQ or MQTT please let us know,
Dasha from HiveMQ team