通过rabbitmqctl set_policy TTL设置消息老化策略删除消息没有反应

fooy5460 发布于 2017/02/09 11:41
阅读 587
收藏 0

rabbitmqctl set_policy TTL ".*" '{"message-ttl":60000}' --apply-to queues

通过上面命令设置TTL策略后,本意想将老化的数据自动删除,但是在多个环境尝试了多次都没有效果; 不清楚原因。

[root@hosta rabbitmq]# rabbitmqctl list_queues name messages|awk '$2>0'
Listing queues ...
metering.sample 2065
notifications.info      1279

 

http://www.rabbitmq.com/ttl.html

To specify a TTL using policy, add the key "message-ttl" to a policy definition. For example:

rabbitmqctl
rabbitmqctl set_policy TTL ".*" '{"message-ttl":60000}' --apply-to queues
rabbitmqctl (Windows)
rabbitmqctl set_policy TTL ".*" "{""message-ttl"":60000}" --apply-to queues

This applies a TTL of 60 seconds to all queues.

When a TTL policy is being applied to a queue which already has messages in it, matching messages will be discarded immediately (with some caveats).

加载中
0
f
fooy5460

补充:空队列时设置策略,后面消息可以老化丢弃;

Caveats

Queues that had a per-message TTL applied to them retroactively (when they already had messages) will discard the messages when specific events occur. Only when expired messages reach the head of a queue will they actually be discarded (or dead-lettered). 

0
Xuanyuan92
Xuanyuan92

我试了一下的你policy,在我本地是可以正常自动删除的

返回顶部
顶部