【原创】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 :

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 。





转载于:https://my.oschina.net/moooofly/blog/142128

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值