title: How can I force a RabbitMQ broker to NACK a message for testing?
body: <p>I'm working on a Spring Boot project using RabbitMQ via Spring AMQP. We'd like to be able to test our app's behavior when a message publish is NACK'd (specifically when the <code>ack</code> argument of <code>PublisherConfirmCallback#confirm</code> is <code>false</code>). However we're having a hard time trying to set up this scenario in an integration test (that is, with the app running, not a unit test).</p>
  
  <p>Just to be clear, we're testing around publisher acknowledgements, not consumer acknowledgements.</p>
  
  <p>We know you can get access to a channel with the RabbitTemplate's <code>execute</code> method, but our RabbitMQ auto-acks, so the message is already gone by the time the channel callback is executed. We're thinking we might be able to either disable auto-ack at runtime (so as not to interrupt the test suite) or to simply block the channel and receive the message on it manually in the test, but we can't figure out how to do either of these. But really, any way to cause a NACK during a test would be great.</p>
  
  <p>tl;dr how to nack a message from client code</p>