简体   繁体   English

是否可能为单个队列设置死信队列

[英]Is it possible to have dead letter queue for individual queues

I currently have a Queue in my ActiveMQ server called hello.world . 我目前在我的ActiveMQ服务器中有一个名为hello.world的Queue。 Whenever a message fails to be processed, ActiveMQ creates a default directory called ActiveMQ.DLQ . 每当消息无法处理时,ActiveMQ都会创建一个名为ActiveMQ.DLQ的默认目录。 Is it possible to change that name to something like hello.world.DLQ ? 是否可以将该名称更改为hello.world.DLQ The reason being is that I might have several queues in the future and I want it to be something like <queue_name>.DLQ 原因是我将来可能有几个队列,我希望它像<queue_name>.DLQ

The thing you are looking for is called Individual Dead letter Queue strategy , in this process ActiveMQ creates specific DLQ for each queue/topic, 您正在寻找的东西称为Individual Dead letter Queue strategy ,在此过程中,ActiveMQ为每个队列/主题创建特定的DLQ,

you can implement it as follows, by tweaking your activemq.xml a bit 您可以通过稍微调整activemq.xml来实现如下

 <destinationPolicy>
    <policyMap>
      <policyEntries>
       <policyEntry queue=">">  <!-- '>' is the wildcard used in ActiveMQ which means for all queues, i.e. same as '*' in any other language -->
        <!-- need to add the following lines in you conf file -->
          <deadLetterStrategy>
            <individualDeadLetterStrategy
              queuePrefix="DLQ." useQueueForQueueMessages="true" />
          </deadLetterStrategy>
        </policyEntry>
      </policyEntries>
    </policyMap>
  </destinationPolicy>

this configuration will create DLQ with names like DLQ.<queue_name> , if you do not want the prefix , you can remove queuePrefix attribute. 此配置将创建名称如DLQ.<queue_name> ,如果不需要前缀,则可以删除queuePrefix属性。

hope this helps! 希望这可以帮助!

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM