MQTTnet
MQTTnet copied to clipboard
How to prevent ack on message consume failure
Hello,
If I am consuming QOS 1 messages, and encounter an error consuming message, how can I prevent the message from being acked? If I have an uncaught exception inside of my client.UseApplicationMessageReceivedHandler handler will it redeliver ?
Thanks,
Colin
You can set MqttApplicationMessageReceivedEventArgs.ProcessingFailed to true. Then no ACK will be sent.
@chkr1011 Shouldn't that be the default when an exception is catched when QoS1 is requested?
So if you want QoS1 you need to do something like the following?
public async Task Handler(MqttApplicationMessageReceivedEventArgs arg)
{
try
{
// Do your magic here
}
catch
{
arg.ProcessingFailed = true;
throw;
}
}
I assume this question in properly answered.