title: Spring Topic Subscriber thread-pooling
body: <p>I have been skimming forums and websites for a few days now about how to thread-pool a spring JMS subscriber with very little luck.  When using a queue with the jms:listener-container there is a concurrency property, however, with a topic it states to keep concurrency at 1.  Given that, what are my options for thread-pooling a topic subscriber?</p>
  
  <p>I started out with the MessageListener route with the implementation of onMessage with:</p>
  
  <pre><code>    &lt;bean id="messageListener" class="com.app.mdp.Receiver"/&gt;
      &lt;jms:listener-container container-type="default"
          connection-factory="connectionFactory" acknowledge="auto" concurrency="1"
          destination-type="topic" prefetch="1"&gt;
          &lt;jms:listener destination="topTopic" ref="messageListener"
              method="onMessage" subscription="ASub" /&gt;
      &lt;/jms:listener-container&gt;
  
      &lt;bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
          &lt;property name="jndiName" value="jms/jms-top-notx" /&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>The problem with this is I get at most one thread receiving data from JMS at a time.</p>
  
  <p>I then attempted to use a task executor with config:</p>
  
  <pre><code>&lt;bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"&gt;
    &lt;property name="corePoolSize" value="10" /&gt;
    &lt;property name="maxPoolSize" value="20" /&gt;
    &lt;property name="queueCapacity" value="0" /&gt;
  &lt;/bean&gt; 
  </code></pre>
  
  <p>..but it seems to require concurrency to be of a greater value in the jms:listener-container setup (unless I am misunderstanding).  Still I only received one thread at a time.</p>
  
  <p>I am at a bit of a loss and starting to think that spring does not have functionality to support multiple threads when subscribing to JMS topic data.  If that is the case my options seem to be:</p>
  
  <ul>
  <li>implement my own thread pool. schedule subscriber->loop through jmsTmplate.receive() data->pass each message to a predefined thread</li>
  <li>revert back to EJBs (which I don't want to do)</li>
  <li>something else I have yet to think of</li>
  </ul>
  
  <p>Any help would be greatly appreciated.</p>