1
votes

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.

1
dead-letter exchange is the solution to your problem.lambodar

1 Answers

3
votes

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: