问题
What are the possible reasons for a Nack to occur in publisher confirm mode, and can a Nack be reliably produced for testing, short of pulling a cable to the disk or other hardware-based actions?
E.g. sending to a non-existing exchange does not lead to a Nack. It leads to a channel close, just like in non-confirm mode.
Btw my rabbit cluster is running on Windows boxes, which might matter, as the file system works quite differently from those in the unix world.
回答1:
One way to generate Nacks is to
- create a virtual hard disk
- configure the environment variable
RABBITMQ_MNESIA_BASEto point to a folder on that drive - reinstall the RabbitMQ service so the changed mnesia base dir is picked up
- restart the service
- take the virtual hard disk offline while enqueueing messages
A test confirmed that that will actually result in a Nack.
来源:https://stackoverflow.com/questions/18116661/evoke-a-nack-in-publisher-confirm-mode