I have a RabbitMQ queue that was originally declared like this:
var result = _channel.QueueDeclare("NewQueue", true, false, false, null);
And I'm trying to add a dead letter exchange, so I've changed the code to this:
_channel.ExchangeDeclare("dl.exchange", "direct");
Dictionary<string, object> args = new Dictionary<string, object>()
{
{ "x-dead-letter-exchange", "dl.exchange" }
};
var result = _channel.QueueDeclare("NewQueue", true, false, false, args);
When I run this, I get the error:
Exception thrown: 'RabbitMQ.Client.Exceptions.OperationInterruptedException' in RabbitMQ.Client.dll
Additional information: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=406, text="PRECONDITION_FAILED - inequivalent arg 'x-dead-letter-exchange' for queue 'NewQueue' in vhost '/': received the value 'dl.exchange' of type 'longstr' but current is none", classId=50, methodId=10, cause=
The error seems pretty self explanatory, and if I delete the queue, when I re-create it, I don't get the error, but my question is: is there a way to make this change without deleting the queue?