ActiveMQ:如何在客户端设置死信策略?

时间:2012-11-22 09:51:09

标签: java jms activemq

我正在实施未发送的消息处理,但存在问题。 可以在服务器端在配置文件中设置死信stratagy(通过队列名称模式),但是我的消息的队列是动态创建的,并且在配置阶段它们的名称是未知的。 所以我想知道是否有可能从客户端设置死信策略?

2 个答案:

答案 0 :(得分:1)

这可能不是您想要的,但根据this,您应该能够在配置中使用通配符>IndividualDeadLetterStrategy,这样您的每个队列都会获得它自己的DLQ。见这部分:

  

如果您愿意,可以使用外卡来应用此策略   队列获得自己的死信队列,如示例中所示   下方。

<broker...>
  <destinationPolicy>
    <policyMap>
      <policyEntries>
        <!-- Set the following policy on all queues using the '>' wildcard -->
        <policyEntry queue=">">
          <deadLetterStrategy>
            <!--
              Use the prefix 'DLQ.' for the destination name, and make
              the DLQ a queue rather than a topic
            -->
            <individualDeadLetterStrategy
              queuePrefix="DLQ." useQueueForQueueMessages="true" />

答案 1 :(得分:0)

在这个link中,你会找到一个如何配置它的例子,这是一个摘录:

<spring:bean id="AmqDeadLetterStrategy"
    class="org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy"
                     p:queuePrefix="DLQ." />

<spring:bean id="AmqDefaultPolicyEntry"
                     class="org.apache.activemq.broker.region.policy.PolicyEntry"
                     p:queue="jobs.*"
                     p:deadLetterStrategy-ref="AmqDeadLetterStrategy" />