Reputation: 3133
I am working with RabbitMq .net and the message acknowledgements. If the consumer is able to process the message we can send back an ack in the form of
channel.BasicAck(ea.DeliveryTag, false);
which will take it off the queue. I would like to move the message to the "error-queue" if I have issues with deserialization
var message = JsonConvert.DeserializeObject<object>(json);
I have tried using "x-dead-letter-exchange" but it depends on "x-message-ttl" time setting. I do only want to move messages to error-queue if processing fails. How to achieve this funcationality? I couldn't find any help online.
Upvotes: 2
Views: 3271
Reputation: 2137
If your consumer rejects the message using basic.reject
or basic.nack
with the requeue
flag set to false
, RabbitMQ will republish the message to the dead-letter exchange. This is documented in the article about dead-letter exchanges.
Here are the functions to reject or nack messages in the RabbitMQ .NET 3.6.10 client:
BasicNack(ulong deliveryTag, bool multiple, bool requeue)
BasicReject(ulong deliveryTag, bool requeue)
Upvotes: 3