title: Only one thread is utilized in the ThreadPoolTaskExecutor and JMS
body: <p>I have a JMS Message Listener under JBoss 5.1, configured by Spring. Although the ThreadPoolTaskExecutor is configured to have a core pool size of 15, I see that only one thread is serving requests, and the others are waiting. According to the <a href="http://download.oracle.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html" rel="nofollow noreferrer">ThreadPoolExecutor API</a> I need to have a bounded queue, but I don't see how spring allow me to do it.</p>
  
  <p>Here is the configuration:</p>
  
  <pre><code>&lt;bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
      &lt;property name="jndiName" value="java:/ConnectionFactory" /&gt;
      &lt;property name="jndiTemplate" ref="jndiTemplate" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
      &lt;property name="jndiName" value="queue/someQueue" /&gt;
      &lt;property name="jndiTemplate" ref="jndiTemplate" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="jmsReceiveDestinationResolver"
      class="org.springframework.jms.support.destination.JndiDestinationResolver"&gt;
      &lt;property name="jndiTemplate" ref="jndiTemplate" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="someListener" class="com.company.SomeListener"&gt;
      &lt;property name="..." ref="..." /&gt;
  &lt;/bean&gt;
  
  &lt;jms:listener-container connection-factory="connectionFactory"
      destination-type="queue" destination-resolver="jmsReceiveDestinationResolver" 
      task-executor="jmsTaskExecutor"&gt;
      &lt;jms:listener destination="queue/someQueue" ref="messageListener" /&gt;
  &lt;/jms:listener-container&gt;
  
  &lt;bean name="jmsTaskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"&gt;
      &lt;property name="corePoolSize" value="15"/&gt;
      &lt;property name="maxPoolSize" value="50"/&gt;       
      &lt;property name="threadNamePrefix" value="some-queue-thread"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Here is the stack trace of the 14 waiting threads:</p>
  
  <pre><code>"some-queue-thread7" prio=10 tid=0x000000004dcfc800 nid=0x1d90 waiting on condition [0x00000000435f7000]
     java.lang.Thread.State: WAITING (parking)
      at sun.misc.Unsafe.park(Native Method)
      - parking to wait for  &lt;0x000000070f5abad8&gt; (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
      at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
      at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987)
      at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:399)
      at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:947)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
      at java.lang.Thread.run(Thread.java:662)
  </code></pre>
  
  <p>Notice this may similar to <a href="https://stackoverflow.com/questions/4269559/spring-threadpooltaskexecutor-only-running-one-thread">Spring ThreadPoolTaskExecutor only running one thread</a>, but in my case the core pool size is larger than 1.</p>