java - How can I force a RabbitMQ broker to NACK a message for testing? -


i'm working on spring boot project using rabbitmq via spring amqp. we'd able test our app's behavior when message publish nack'd (specifically when ack argument of publisherconfirmcallback#confirm false). we're having hard time trying set scenario in integration test (that is, app running, not unit test).

just clear, we're testing around publisher acknowledgements, not consumer acknowledgements.

we know can access channel rabbittemplate's execute method, our rabbitmq auto-acks, message gone time channel callback executed. we're thinking might able either disable auto-ack @ runtime (so not interrupt test suite) or block channel , receive message on manually in test, can't figure out how either of these. really, way cause nack during test great.

tl;dr how nack message client code

you have turn off auto-ack, start with. turned on, not possible nack message.

after that, you're test setup should include message consumer coded want, when want... don't use real code test nack handling. set consumer nack... or 1 knows when receives messages, should nack


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -