ActiveMQ:如何防止消息转到 "Dispatched Queue"

ActiveMQ: How to prevent message from going to "Dispatched Queue"

我在 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>

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

我发布的以上设置有效!

谢谢!