[rabbitmq-discuss] How to setup dead-letter queue in C# ?

Matthias Radestock matthias at rabbitmq.com
Mon Dec 10 19:57:25 GMT 2012

On 10/12/12 16:11, Johan Klijn wrote:
> I changed the code at some places, without any luck.

This isn't quite as minimal as I suggested.

The following works fine for me:

public static void Main(string[] args) {
     ConnectionFactory cf = new ConnectionFactory();
     using (IConnection conn = cf.CreateConnection()) {
         using (IModel ch = conn.CreateModel()) {
             ch.QueueDeclare("DeadLetterQueue", true, false, false, null);
             ch.QueueBind("DeadLetterQueue", "amq.fanout", "");
             Hashtable arguments = new Hashtable()
                     {"x-dead-letter-exchange", "amq.fanout"}
             ch.QueueDeclare("MessageQueue", true, false, false, arguments);
             ch.BasicPublish("", "MessageQueue", null, new byte[0]);
             BasicGetResult result = ch.BasicGet("MessageQueue", false);
             ch.BasicNack(result.DeliveryTag, false, false);

Also, as I asked in my previous email, are you definitely running 
RabbitMQ >= 2.8.0 (since that is when dead-lettering was introduced)?



More information about the rabbitmq-discuss mailing list