title: Spring with AMQP and RabbitMQ, queue with optional x-dead-letter-exchange
body: <p>I have an existing queue created in RabbitMQ. It can be created with or without <code>x-dead-letter-exchange</code> parameter. I am creating a consumer of this queue in Spring using the RabbitTemplate. When I declare the queue, I don't want to specify the <code>x-dead-letter-exchange</code> parameter. I would like the template to somehow figure it itself or not care. I am throwing <code>AmqpRejectAndDontRequeueException</code> from my consumer to indicate bad messages, but I want the creator of the queue to be responsible for the decision whether or not to create an exchange and queue for the rejected messages.</p>
  
  <p>Here is my bean that declares the queue in Spring:</p>
  
  <pre><code>@Bean
  Queue queue() {
      Map&lt;String, Object&gt; args = new HashMap&lt;&gt;();
      // set the queue with a dead letter feature
      args.put("x-dead-letter-exchange", REJECTED_EXCHANGE);
      args.put("x-dead-letter-routing-key", REJECTED_ROUTING_KEY);
      Queue queue = new Queue(Constants.QUEUE_NAME, false, false, false, args);
      return queue;
  }
  </code></pre>
  
  <p>This works fine, but when the creator of the queue decides not to use the dead letter feature, I see the following error:</p>
  
  <pre><code>Channel shutdown: channel error; protocol method: #method&lt;channel.close&gt;
  (reply-code=406, reply-text=PRECONDITION_FAILED - 
  inequivalent arg 'x-dead-letter-exchange' for queue 'queueName'
  </code></pre>
  
  <p>The message is a bit longer, it continues telling me which side has which <code>x-dead-letter-exchange</code> (none or a name of the exchange). I've tried different combinations (e.g. creating the queue with exchange and not specifying it in the Spring or creating the queue without the exchange and specifying it in the Spring), only to see different variants of this message.</p>
  
  <p>How do I declare the queue so it simply accepts whatever parameters are already set in the queue? </p>