【问题标题】:ActiveMQ: how to set dead letter strategy on client side?ActiveMQ:如何在客户端设置死信策略?
【发布时间】:2012-11-10 16:28:08
【问题描述】:

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

【问题讨论】:

    标签: java jms activemq


    【解决方案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" />
    

    【讨论】:

    • 客户端没办法设置,这是解决问题的最好办法。
    【解决方案2】:

    在这个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" />
    

    【讨论】:

      猜你喜欢
      • 2021-07-31
      • 1970-01-01
      • 2020-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-03
      相关资源
      最近更新 更多