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

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

问题描述

我正在使用 RabbitMQ 服务器.

I am using RabbitMQ server.

为了发布消息,我将 immediate 字段设置为 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.

然后,我将 immediate 标志更改为 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.

任何人都可以帮助我理解 立即 位字段和这种行为吗?另外,我无法理解 mandatory 位字段的概念.

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澄清其实施者如何解释其含义的常见问题解答:

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

或者用我的话来说,如果此刻至少有一个消费者连接到我的队列可以接收消息,请立即将该消息传递给他们.如果没有连接的消费者,那么就没有指出我的消息稍后会被消费,他们永远不会看到它.他们打盹,他们输了."

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

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