【问题标题】:ActiveMQ: How to prevent message from going to "Dispatched Queue"ActiveMQ:如何防止消息进入“调度队列”
【发布时间】:2016-03-10 21:54:44
【问题描述】:

我在 Spring 框架中使用 ActiveMQ。

我在 jms 容器中设置了两个消费者。当我向队列发送 4 条消息时,一些消息被转移到“Dispatched Queue”,因为消费者处理消息需要很长时间。

我正在尝试找到阻止消息进入“Dispatched Queue”的方法,也就是说,我希望它们可供任何准备好使用该消息的消费者使用。

我尝试将预取设置为 0,但它似乎根本不起作用。

<bean id="prefetchPolicy" class="org.apache.activemq.ActiveMQPrefetchPolicy">
  <property name="queuePrefetch" value="0"/>
</bean>

<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
  <constructor-arg index="0" value="tcp://localhost:61616" />
  <property name="prefetchPolicy" ref="prefetchPolicy"/>
</bean>

以下是我的 jms 容器的设置:

    <bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
        <property name="connectionFactory" ref="connectionFactory"/>
        <property name="destination" ref="defaultDestination" />
        <property name="messageListener" ref="messageListener" />
        <property name="concurrentConsumers" value="2" />
    </bean>

【问题讨论】:

    标签: java spring jms activemq


    【解决方案1】:

    我发现了问题。我在两个不同的地方两次声明了相同的豆子。加载的第二个 bean 没有将 pre-fetch 设置为 0,因此没有成功。

    我发布的上述设置有效!

    谢谢!

    【讨论】:

      猜你喜欢
      • 2021-11-20
      • 2011-09-17
      • 2018-04-23
      • 2015-09-23
      • 2018-11-30
      • 2022-06-14
      • 2021-12-26
      • 2017-02-23
      • 1970-01-01
      相关资源
      最近更新 更多