1
votes

I'm using ActiveMQ with the spring framework.

I have two consumers setup in the jms container. 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.

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.

<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:

    <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>
1

1 Answers

1
votes

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.

The above setup I posted works!

Thank you!