简体   繁体   English

ActiveMQ:如何防止消息进入“分派队列”

[英]ActiveMQ: How to prevent message from going to “Dispatched Queue”

I'm using ActiveMQ with the spring framework. 我在Spring框架中使用ActiveMQ。

I have two consumers setup in the jms container. 我在jms容器中设置了两个使用者。 When I send 4 message to the queue, and some of the message are transferred to the "Dispatched Queue", because it takes a long time to the consumer to process the message. 当我向队列发送4条消息时,一些消息被传输到“分派队列”,因为消费者需要花费很长时间来处理该消息。

I'm trying to find the way to prevent the message from going to the "Dispatched Queue", that is, I want them to be available to any consumer that is ready to consume the message. 我正在尝试找到防止消息进入“分派队列”的方法,也就是说,我希望任何准备使用该消息的使用者都可以使用它们。

I tried to set pre-fetch to 0, but it doesn't seem to work at all. 我试图将预取设置为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> 

The following is the setup for my jms container: 以下是我的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> 

I found the problem. 我发现了问题。 I had the same beans declared twice at two different places. 我在两个不同的地方两次声明了相同的豆子。 The second bean that was loaded did not have pre-fetch set to 0 and therefore it didn't work out. 加载的第二个Bean的预取未设置为0,因此无法正常工作。

The above setup I posted works! 我发布的上述设置有效!

Thank you! 谢谢!

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

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