ActiveMQ死信队列使用

来源:互联网 发布:java程序员看什么书 编辑:程序博客网 时间:2024/06/06 17:30

现状:

由于测试环境应用复杂的原因,造成了jms死信队列一直挤压很多数据,从而导致存储爆满,进而造成了各个客户端不能正常发送消息。
针对这些死信队列,一般都没有利用价值的。测试一般都关注某模块!
为了避免某队列的死信队列的挤压,而使整个jms不可用,我们选择了通过ActiveMQ的配置,直接丢弃掉死信队列的消息。


自动丢弃过期消息(Expired Messages)

简单丢弃过期消息,而不将它们放到DLQ中,完全跳过DLQ。
在dead letter strategy死信策略上配置processExpired属性为false,可以实现这个功能。

    <broker...>  
      <destinationPolicy>  
       <policyMap>  
         <policyEntries>  
           <!-- Set the following policy on all queues using the '>' wildcard -->  
           <policyEntry queue=">">  
             <!--  
               Tell the dead letter strategy not to process expired messages  
               so that they will just be discarded instead of being sent to  
               the DLQ  
             -->  
             <deadLetterStrategy>  
               <sharedDeadLetterStrategy processExpired="false" />  
             </deadLetterStrategy>  
           </policyEntry>  
         </policyEntries>  
       </policyMap>  
      </destinationPolicy>  
    ...  
    </broker>  


原创粉丝点击