rabbitmq - 过期的消息不会从 RabbitMQ 中删除

标签 rabbitmq messages ttl

我通过生产者向 RabbitMQ 发送一条普通消息,然后用 expiration 发送第二条消息。分配给值的属性。然后使用 rabbitmqctl list_queues命令我监视消息的状态。

我发现如果我先发送一条普通消息,然后再发送一条消息 expiration , rabbitmqctl list_queues总是向我显示队列中待处理的 2 条消息。当我消费它们时,我只得到一个。

另一方面,如果我只用 expiration 发送 1 条消息,一开始我看到消息,然后在正确的到期时间之后,我发现它被删除了。

我的问题是,第一种情况实际上是消息占用空间?或者它是一个界面错误?

我的rabbitMQ版本是:rabbitmq-server.noarch -> 3.1.5-1.el6

最佳答案

看起来您错过了有关此功能的一些文档。如果您阅读了 RabbitMQ documentation on per-message TTL (expiration) ,您会注意到针对您所看到的行为的以下警告(强调):

Caveats

While consumers never see expired messages, only when expired messages reach the head of a queue will they actually be discarded (or dead-lettered). When setting a per-queue TTL this is not a problem, since expired messages are always at the head of the queue. When setting per-message TTL however, expired messages can queue up behind non-expired ones until the latter are consumed or expired. Hence resources used by such expired messages will not be freed, and they will be counted in queue statistics (e.g. the number of messages in the queue).

关于rabbitmq - 过期的消息不会从 RabbitMQ 中删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27991503/

相关文章:

c# - 通过 ThreadLocal 访问 RabbitMQ IModel 是否有任何影响或陷阱?

spring - Spring 如何管理与 RabbitMQ 的 websocket 连接?

scala - Actor 可以在特定条件下读取消息吗?

c# - WCF 错误 : Manual addressing is enabled on this factory, 所以发送的所有消息都必须预先寻址

cassandra - cassandra 中 TTL 的最大值

python - Celery 动态队列创建和路由

python - 用于 AMQP 的优秀 Python 库

validation - 防止 p :messages component from showing messages which are already shown in p:message

crash - 使用 Rabbitmq 并设置 ttl = 0 时如何使消息自动重试?

java - 设置 "networkaddress.cache.ttl"的最佳方法