1 Reply Latest reply on Jan 4, 2018 12:54 PM by jbertram

    Prevent JMS prefetching of messages


      I'm using JMS queues which are defined within JBoss, and have consumers in Apache Tomcat that are accessing the queues using the Spring DefaultMessageListenerContainer with a cachedConnectionFactory.


      This is working fine for me, except for one problem.  The processing of each individual message takes a long time (about 30 minutes), and it seems that either the consumer is prefetching records from the queue, or the JBoss queue is sending the consumer multiple at a time, and I'm unable to find a way to confirm that this happenning, nor a way to control it.


      In my case, I have 7 consumers (limited to each consume one message at a time), and what is happenning is that if I publish 30 messages into the queue, I'll see that everything will be running fine until I reach the last few, at which point I'll see that I have idle consumers, 1 message being processed, and 1 or more messages that are not yet consumed.  After the one running job completes, the remaining messages then come through on the same consumer.


      I'd like to be able to control this so that each consumer is holding only one message at a time.  (I don't want to use prefetching)  Does anyone know where I may start in order to prove that it is in fact doing something similar to a prefetch, and do you know if there is anything that I can do to prevent this from happening?


      Environment is JBoss 5.1 with Tomcat 6 and Spring 2.5.


      Thanks -


      (Sample Spring ApplicationContext is below)




      <bean id="jmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">

           <property name="lookupOnStartup" value="false" />

          <property name="cache" value="false" />

          <property name="proxyInterface" value="javax.jms.ConnectionFactory" />

           <property name="jndiTemplate">

                <ref bean="jndiTemplate" />


           <property name="jndiName">





      <bean id="cachedConnectionFactory"


           <property name="reconnectOnException" value="true" />

           <property name="targetConnectionFactory">

                <ref bean="jmsConnectionFactory" />


           <property name="sessionCacheSize">






      <bean id="listenerContainer"



           <property name="autoStartup" value="${jms.enable}" />

           <property name="concurrentConsumers" value="1" />

           <property name="connectionFactory" ref="cachedConnectionFactory" />

           <property name="destinationResolver" ref="jmsDestinationResolver" />

           <property name="destinationName" value="${jms.queue}" />

           <property name="messageListener" ref="messageListener" />

           <property name="sessionTransacted" value="true" />