RabbitMQ Change Queue

October 20, 2016

Whilst trying to add a dead letter exchange to an existing queue, I got the following 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=

There is a clue is in the error message:

…received the value ‘dl.exchange’ of type ‘longstr’ but current is none

So, the problem is that the exchange is changing.

One solution is to delete the queue:


This didn’t feel right, so I asked, and it turns out you can’t do this in code.

Also, remember that both the publisher and subscriber need to change the code, otherwise, the publisher will re-declare the queue without the exchange. Not that this happened to me - I realised that straight away, and didn’t spend an hour trying to work out why even deleting the queue didn’t work.

Profile picture

A blog about one man's journey through code… and some pictures of the Peak District

© Paul Michaels 2024