我已经使用RabbitMQ服务器并在 immediate 字段设置为true时发布消息,我尝试发送50,000条消息并使用 rabbitmqctl list_queues ,我看到队列中的消息数量为 zero . 然后我将 immediate 标志更改为false并再次尝试发送50,000条消息然后使用 rabbitmqctl list_queues 我看到总共100,000条消息在队列中 . (直到现在还没有消费者存在)
之后我开始使用消费者并消耗了所有100,000条消息 . 任何人都可以帮助我理解 immediate 位字段和这种行为 . 另外,我无法理解 mandatory 位字段的概念 .
提前感谢 .
Gurpreet Singh .
2 回答
immediate
和mandatory
字段是AMQP规范的一部分,RabbitMQ常见问题解答中也包含这些字段,以阐明其实现者如何解释其含义:Mandatory
或者用我的话说,"Put this message on at least one queue. If you can't, send it back to me."
Immediate
或者用我的话来说,"If there is at least one consumer connected to my queue that can take delivery of a message right this moment, deliver this message to them immediately. If there are no consumers connected then there's no point in having my message consumed later and they'll never see it. They snooze, they lose."
http://www.rabbitmq.com/blog/2012/11/19/breaking-things-with-rabbitmq-3-0/
刚刚复制了这里的公告,以便快速参考 .