I've got a JMS connectionFactory that a number of spring integration jms inbound-gateways use. They work fine, but only one message at a time. I'd like to make them handle N concurrent messages at a time in different threads.
The code I've got now is as follows.
spring-config.xml
<import resource="commons/jmsConnectionFactory.xml"/>
<import resource="chain/chain1.xml"/>
<import resource="chain/chain2.xml"/>
jmsConnectionFactory.xml
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL">
<value>failover:(tcp://mqmaster:61616,tcp://mqslave:61616)?jms.prefetchPolicy.all=1&randomize=false</value>
</property>
</bean>
chains all look something like this
<int:channel id="fooChannel"/>
<int-jms:inbound-gateway request-channel="fooChannel" request-destination-name="foo" extract-request-payload="true" />
<int:chain input-channel="fooChannel">
<int-http:outbound-gateway
url="...."
http-method="GET"
extract-request-payload="true" />
<int:object-to-string-transformer />
</int:chain>
I know that I can add "concurrent-consumers" and "max-concurrent-consumers" to the inbound-gateway to make the gateway process multiple messages. That would result though in having each chain/gateway handling it's threads managed independently. I would like some way to define a common thread pool for everyone using the JMS connection. This would allow me to specify 5 threads and have them allocated among the gateways based on what messages the server is supplying, but constraining the consuming server to a manageable amount of work.
What modifications are needed to do the processing with multiple threads? And how do I limit the number of threads?