activemq死信队列
DLQ-死信队列(Dead Letter Queue)用来保存处理失败或者过期的消息。
出现以下情况时,消息会被redelivered:
A transacted session is used and rollback() is called.
A transacted session is closed before commit is called.
A session is using CLIENT_ACKNOWLEDGE and Session.recover() is called.
当一个消息被redelivered超过maximumRedeliveries(缺省为6次,具体设置请参考后面的链接)次数时,会给broker发送一个\"Poison ack\",这个消息被认为是a poison pill,这时broker会将这个消息发送到DLQ,以便后续处理。
缺省的死信队列是ActiveMQ.DLQ,如果没有特别指定,死信都会被发送到这个队列。
缺省持久消息过期,会被送到DLQ,非持久消息不会送到DLQ可以通过配置文件(activemq. )来调整死信发送策略。
activemq. 配置
添加相应的配置到 文件中。
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry queue=\">\">
<deadLetterStrategy>
<individualDeadLetterStrategy queuePrefix=\"DLQ.\" useQueueForQueueMessages=\"true\"/>
</deadLetterStrategy>
</policyEntry>
<policyEntry topic=\">\" >
<!-- The constantPendingMessageLimitStrategy is used to prevent
slow topic consumers to block producers and affect other consumers
by limiting the number of messages that are retained
For more information, see:
http://activemq.apache.org/slow-consumer-handling.html
-->
<pendingMessageLimitStrategy>
<constantPendingMessageLimitStrategy limit=\"1000\"/>
</pendingMessageLimitStrategy>
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy>
测试
通过测试死信队列三种情况的一种,到浏览器查验。
继续阅读与本文标签相同的文章
-
谷歌AI模型ML-Jam激发音乐家创作,人机合作或成未来大势!
2026-05-19栏目: 教程
-
OCP-052考试题库汇总(49)-CUUG内部解答版
2026-05-19栏目: 教程
-
自己实现 ECS 购买页需要用到的 API
2026-05-19栏目: 教程
-
Istio从懵圈到熟练 – 二分之一活的微服务
2026-05-19栏目: 教程
-
又一个里程碑,谷歌发布最新研究,机器学习开辟新篇章!
2026-05-19栏目: 教程
