Artemis STOMP 消息过期

Artemis STOMP message expiry

根据文档,我仍然不明白如何在 broker.xml 中为 STOMP 协议配置消息过期。

我们有一个聊天项目,其中为每个聊天创建“多播”地址

topic/chat.1, topic/chat.2, ..., topic/chat.100000

除其他外,我们使用“Durable Subscriptions”。 因此,即使在我们不受欢迎的项目上,每月的主题数也可能超过 50,000,这会导致服务器 运行 内存不足,尤其是当我们转到 Web 控制台时。

希望在删除过期消息时,自动删除不需要的地址和队列

您可以使用 the documentation 中提到的 expiry-delay address-setting 对所有传入消息应用过期,例如:

<address-setting match="#">
   <expiry-delay>300000</expiry-delay> <!-- 5 minutes -->
</address-setting>

如果您使用的是 ActiveMQ Artemis 2.12.0 或更高版本,那么当最后一条消息从没有消费者的 auto-created 队列中过期时,默认情况下该队列将为 auto-deleted(如果对应的auto-created地址没有队列,默认也是auto-deleted)。