RabbitMQ使用立即位和强制位 [英] RabbitMQ use of immediate and mandatory bits

查看:119
本文介绍了RabbitMQ使用立即位和强制位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用RabbitMQ服务器.

I am using RabbitMQ server.

对于发布消息,我将立即字段设置为 true 并尝试发送50,000条消息.使用rabbitmqctl list_queues,我看到队列中的邮件数量为.

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.

然后,我将立即标志更改为 false ,然后再次尝试发送50,000条消息.使用rabbitmqctl list_queues,我看到队列中总共有100,000条消息(到现在为止,没有使用者.)

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).

此后,我启动了一个使用者,它消耗了所有100,000条消息.

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.

推荐答案

immediatemandatory字段是AMQP规范的一部分,RabbitMQ FAQ中也包含了这些字段,以阐明其实现者如何解释其含义:

The immediate and mandatory fields are part of the AMQP specification, and are also covered in the RabbitMQ FAQ to clarify how its implementers interpreted their meaning:

必填

此标志告诉服务器如何 如果无法将消息路由到,则做出反应 一个队列.具体来说,如果强制性是 设置并运行绑定后 然后将邮件放在零队列中 邮件返回给发件人 (带有basic.return).如果必须 没有设置在相同的 服务器会在什么情况下 默默地删除邮件.

This flag tells the server how to react if a message cannot be routed to a queue. Specifically, if mandatory is set and after running the bindings the message was placed on zero queues then the message is returned to the sender (with a basic.return). If mandatory had not been set under the same circumstances the server would silently drop the message.

或者用我的话说,将这条消息至少放在一个队列中.如果不能,将其发送回给我."

立即

有关立即发布的消息 设置,如果匹配的队列已经准备好 消费者,那么其中之一将拥有 邮件路由到它.如果幸运的话 消费者在确认之前崩溃 收到邮件后将重新排队 和/或交付给其他消费者 该队列(如果没有崩溃, 消息已确认并全部完成 按照正常).但是,如果 匹配队列准备就绪为零 消费者的消息不会 排队供以后重新交付 从那个队列.只有所有 匹配的队列还没有准备好 消费者该消息已返回 发送给发件人(通过basic.return).

For a message published with immediate set, if a matching queue has ready consumers then one of them will have the message routed to it. If the lucky consumer crashes before ack'ing receipt the message will be requeued and/or delivered to other consumers on that queue (if there's no crash the messaged is ack'ed and it's all done as per normal). If, however, a matching queue has zero ready consumers the message will not be enqueued for subsequent redelivery on from that queue. Only if all of the matching queues have no ready consumers that the message is returned to the sender (via basic.return).

或者用我的话说,"如果此时至少有一个连接到我的队列的消费者可以接收消息,则立即将此消息传递给他们.如果没有连接的消费者,则没有消息指向稍后再使用我的消息,他们将再也看不到.他们打oo睡,他们迷路了."

这篇关于RabbitMQ使用立即位和强制位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆