【原创】RabbitMQ 之 Queue Length Limit(翻译)

简介:

Queue Length Limit

The maximum length of a queue can be limited to a set number of messages by supplying the x-max-lengthqueue declaration argument with a non-negative integer value. Queue length is a measure that takes into account ready messages, ignoring unacknowledged messages and message size. Messages will be dropped or dead-lettered from the front of the queue to make room for new messages once the limit is reached.
一个 queue 中消息最大保存量可以在声明 queue 的时候通过设置 x-max-length 参数为非负整数进行指定。Queue 长度的选取需要考量 就绪消息量、被忽略的未确认消息量,以及消息大小。当 queue 中的消息量达到了设定的上限时,为了给新消息腾出空间,将会从该 queue 用于保存消息的队列的前端将“老”消息丢弃或者 dead-lettered 

This example in Java declares a queue with a maximum length of 10 messages:
下面的 Java 示例展示了如何声明一个最多保存 10 条消息的 queue :

?
1
2
3
Map<String, Object> args = new HashMap<String, Object>();
args.put( "x-max-length" , 10 );
channel.queueDeclare( "myqueue" , false , false , false , args);

Configuration using policy  

To specify a maximum length using policy, add the key "max-length" to a policy definition. For example:
通过 policy 对 queue 的最大长度进行设置,例如可以在 policy 的定义中使用 key “max-length”:  

rabbitmqctl
rabbitmqctl set_policy Ten "^short$" '{"max-length":10}' --apply-to queues
rabbitmqctl (Windows)
rabbitmqctl set_policy Ten "^short$" "{""max-length"":10}" --apply-to queues

This applies a maximum length of 10 to the queue called short.
这使得名字叫 short 的 queue 的最大消息保存量被限制在 10 。  

Policies can also be defined using the management plugin, s   ee the policy documentation for mo   re details.
同样可以使用管理插件来指定 policy ,参见    policy documentation 。  

相关实践学习
RocketMQ一站式入门使用
从源码编译、部署broker、部署namesrv,使用java客户端首发消息等一站式入门RocketMQ。
消息队列 MNS 入门课程
1、消息队列MNS简介 本节课介绍消息队列的MNS的基础概念 2、消息队列MNS特性 本节课介绍消息队列的MNS的主要特性 3、MNS的最佳实践及场景应用 本节课介绍消息队列的MNS的最佳实践及场景应用案例 4、手把手系列:消息队列MNS实操讲 本节课介绍消息队列的MNS的实际操作演示 5、动手实验:基于MNS,0基础轻松构建 Web Client 本节课带您一起基于MNS,0基础轻松构建 Web Client
目录
相关文章
|
2月前
|
消息中间件 监控 算法
高效排队,紧急响应:RabbitMQ Priority Queue全面指南【RabbitMQ 九】
高效排队,紧急响应:RabbitMQ Priority Queue全面指南【RabbitMQ 九】
55 0
|
3月前
|
消息中间件 存储 Java
RabbitMQ中的Queue是什么?它的特点是什么?
RabbitMQ中的Queue是什么?它的特点是什么?
27 0
|
4月前
|
消息中间件 负载均衡 算法
RocketMQ源码(三)简单探索Producer和Consumer与Queue之间的负载均衡策略
- Producer如何将消息负载均衡发送给queue? - Consumer如何通过负载均衡并发消费queue的消息?
458 0
|
4月前
|
消息中间件 Shell Docker
百度搜索:蓝易云【docker rabbitmq-清空queue队列数据】
通过以上步骤,您可以使用Docker清空RabbitMQ队列的数据。这将帮助您重置队列并清除旧数据,以进行新的测试或使用。
33 0
|
6月前
|
消息中间件 存储 算法
RabbitMQ之Queue(队列)属性解读
RabbitMQ之Queue(队列)属性解读
|
9月前
|
消息中间件 中间件 C#
C# Queue与RabbitMQ的爱恨情仇(文末附源码):Q与MQ消息队列简单应用(二)
C# Queue与RabbitMQ的爱恨情仇(文末附源码):Q与MQ消息队列简单应用(二)
|
9月前
|
消息中间件 存储 C#
C# Queue与RabbitMQ的爱恨情仇(文末附源码):Q与MQ消息队列简单应用(一)
C# Queue与RabbitMQ的爱恨情仇(文末附源码):Q与MQ消息队列简单应用(一)
|
消息中间件 Java Spring
【RabbitMQ】Basic Queue 简单队列模型与WorkQueue
【RabbitMQ】Basic Queue 简单队列模型与WorkQueue
75 0
【RabbitMQ】Basic Queue 简单队列模型与WorkQueue
|
消息中间件 PHP
laravel6 使用rabbitmq报错:Call to a member function make() on null at Queue\\Jobs\\Job.php:215
laravel6 使用rabbitmq报错:Call to a member function make() on null at Queue\\Jobs\\Job.php:215
131 0
|
消息中间件 Java 容器
SpringBoot如何做到自动帮我们创建RabbitMQ的Queue和Exchange
SpringBoot如何做到自动帮我们创建RabbitMQ的Queue和Exchange
SpringBoot如何做到自动帮我们创建RabbitMQ的Queue和Exchange