title: DLX in rabbitmq and spring-rabbitmq - some considerations of rejecting messages
body: <p>I did read this reference: <a href="https://www.rabbitmq.com/dlx.html" rel="nofollow noreferrer">https://www.rabbitmq.com/dlx.html</a>, however it doesn't resolve my doubts, namely:<br>
  In case of accepting message there is no problem - <code>spring-rabbitmq</code> send ack and everthing is fine, <code>DLX</code> doesn't know about acked message.   </p>
  
  <p>The problem is in case rejecting answer, namely what about throwing <code>MessageConverterException</code> ?  This message is removed or moved to <code>DLX</code>?  </p>
  
  <p>And what about in case other exception ? For example <code>Exception</code> ?  It is removed/requeued/moved to <code>DLX</code> ?   </p>
  
  <p><strong>Edit after answer of @Gary</strong><br>
  I think, that after answer's @Gary I should add more details about my case and some summary of @Gary's answer. @Gary exactly grasped my use case. </p>
  
  <p>I wouldn't like requeue - never (I am afraid of looping), but I wouldn't like to lose messages when an exception was thrown  (for example lost connection to database) - this message should be resend to <code>DLX</code>. On the other hand,  conversion of message should be treated as fatal error - no requeue, no resend to DLX - simply permanent removing message. <strong>Generally, in depends on exception either reject (=resend to DLX if configured) or accept, never requeue.</strong>  </p>
  
  <p>To sum up in a nutshell approach proposed by @Gary.<br>
  <strong>First</strong>: We can override <code>ExceptionHandler</code> to manage of sending nack/ack, which gives to us a full control.<br>
  <strong>Second</strong>: IMO simpler, solution is to set <code>defaultRequeueRejected=false</code>  and in converter throw <code>ImmediateAcknowledgeAmqpException</code>. It makes that <code>RabbitMQ</code> think that answer was accepted (the same thing as in case of first solution), moreover listener wouldn't be invoked.  <code>
  **Conclusion**: Using</code>ImmediateAcknowledgeAmqpException<code>or</code>ExceptionHandler` exception we have a full control on permanent rejecting message (under hood ack)  and resending to DLX.   </p>