码迷,mamicode.com
首页 > 其他好文 > 详细

ActiveMQ_5死信队列

时间:2018-12-13 19:33:51      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:mit   调整   添加   通过   pen   mat   tin   messages   队列   

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.xml)来调整死信发送策略。

 

activemq.xml配置

       添加相应的配置到xml文件中。

<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>

 

测试

       通过测试死信队列三种情况的一种,到浏览器查验。

 

ActiveMQ_5死信队列

标签:mit   调整   添加   通过   pen   mat   tin   messages   队列   

原文地址:https://www.cnblogs.com/zhiboluo/p/10115296.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!