RabbitMQ 使用立即位和强制位
我正在使用 RabbitMQ 服务器。
对于发布消息,我将 immediate 字段设置为 true 并尝试发送 50,000 条消息。使用rabbitmqctl list_queues
,我看到队列中的消息数量零。
然后,我将 immediate 标志更改为 false 并再次尝试发送 50,000 条消息。使用rabbitmqctl list_queues,我看到队列中总共有100,000条消息(到目前为止,没有消费者存在)。
之后,我启动了一个消费者,它消耗了所有 100,000 条消息。
有人可以帮助我理解立即位字段和这种行为吗?另外,我无法理解强制位字段的概念。
I am using RabbitMQ server.
For publishing messages, I set the immediate field to true and tried sending 50,000 messages. Using rabbitmqctl list_queues
, I saw that the number of messages in the queue was zero.
Then, I changed the immediate flag to false and again tried sending 50,000 messages. Using rabbitmqctl list_queues
, I saw that a total of 100,000 messages were in queues (till now, no consumer was present).
After that, I started a consumer and it consumed all the 100,000 messages.
Can anybody please help me in understanding about the immediate bit field and this behavior too? Also, I could not understand the concept of the mandatory bit field.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
immediate
和mandatory
字段是 AMQP 规范的一部分,并且也在 RabbitMQ 常见问题解答中进行了介绍,以阐明其实现者如何解释其含义:强制
或者用我的话来说,“将此消息放入至少一个队列。如果不能,请将其发送回给我。”
立即
或者用我的话说,“如果至少有一个消费者连接到我的队列,此时可以立即传递消息,请立即将此消息传递给他们。如果没有消费者连接,那么就没有意义我的消息稍后被消耗,他们永远不会看到它,他们打瞌睡,他们输了。”
The
immediate
andmandatory
fields are part of the AMQP specification, and are also covered in the RabbitMQ FAQ to clarify how its implementers interpreted their meaning:Mandatory
Or in my words, "Put this message on at least one queue. If you can't, send it back to me."
Immediate
Or in my words, "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/break-things-with-rabbitmq-3-0/
只是将公告复制到此处以供快速参考。
http://www.rabbitmq.com/blog/2012/11/19/breaking-things-with-rabbitmq-3-0/
Just copied the announcement here for a quick reference.