title: DefaultMessageListenerContainer consuming messages intermittently
body: <p>I have the following configuration for consuming messages from a queue. I need to make sure that the task executor should perform only one task at a time and hence I have configured the task executor too as follows. </p>
  
  <pre><code>&lt;bean name="jmsTaskExecutor"
      class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"&gt;
      &lt;property name="corePoolSize" value="1" /&gt;
      &lt;property name="maxPoolSize" value="2" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>When I configure my task Executor as above, 10 messages are getting consumed at a time (there is a huge flow of messages in the queue) and the container stops listening messages for almost 10-15 minutes.My container is configured as follows:</p>
  
  <pre><code>&lt;bean id="queueContainer"
      class="org.springframework.jms.listener.DefaultMessageListenerContainer"&gt;
      &lt;property name="connectionFactory" ref="cachedConnectionFactory" /&gt;
      &lt;property name="destination" ref="queue" /&gt;
      &lt;property name="maxConcurrentConsumers" value="1" /&gt;
      &lt;property name="idleTaskExecutionLimit" value="1" /&gt;
      &lt;property name="idleConsumerLimit" value="5" /&gt;
      &lt;property name="receiveTimeout" value="10000" /&gt;
      &lt;property name="recoveryInterval" value="10000" /&gt;
      &lt;property name="taskExecutor" ref="jmsTaskExecutor" /&gt;
      &lt;property name="messageListener" ref="queueListener" /&gt;
      &lt;property name="autoStartup" value="true" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>After doing a little bit of googling, i tried to use SyncTaskExecutor instead of ThreadPoolTaskExecutor and I have configured my taskExecutor as follows:</p>
  
  <pre><code>&lt;bean name="jmsTaskExecutor"
              class="org.springframework.core.task.SyncTaskExecutor" /&gt;
  </code></pre>
  
  <p>but that is causing a memory leak in tomcat. </p>
  
  <p>Can you please let me know how I can achieve the behavior of consuming messages and handling the message to the task only after the task is completed?</p>
  
  <p>Queue Listener Code is as follows:</p>
  
  <pre><code>public class QueueListener implements SessionAwareMessageListener&lt;Message&gt;{
   @override
   public void onMessage(Message msg,Session ses) throws JMSException{
   ....
   ....
   ....
   }
  }
  </code></pre>