currently i'm using a CachedConnectionFactory from spring to limit the number of open sessions.
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory" destroy-method="destroy"> <property name="targetConnectionFactory" ref="amqConnectionFactory" /> <property name="sessionCacheSize" value="60" /> </bean> <bean id="amqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"> <property name="brokerURL" value="vm://localhost:61616?async=false&jms.alwaysSessionAsync=true" /> <property name="userName" value="admin" /> <property name="password" value="admin" /> </bean> together with the connection uri parameters this means that activemq uses one thread per session to process messages in the simplemessagelistenercontainer instances and there is a maximum of 60 concurrent sessions. my problem with this config is that fore some reasons sessions are closed by the cached factory to early which causes exceptions like this: 2012-06-12 11:46:06,051 DEBUG [ActiveMQ Session Task-19] o.s.j.l.SimpleMessageListenerContainer - Listener exception after container shutdown javax.jms.IllegalStateException: The Session is closed at org.apache.activemq.ActiveMQSession.checkClosed(ActiveMQSession.java:722) ~[activemq-core-5.5.1.jar:5.5.1] at org.apache.activemq.ActiveMQSession.getTransacted(ActiveMQSession.java:520) ~[activemq-core-5.5.1.jar:5.5.1] at sun.reflect.GeneratedMethodAccessor72.invoke(Unknown Source) ~[na:na] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_04] at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_04] at org.springframework.jms.connection.CachingConnectionFactory$CachedSessionInvocationHandler.invoke(CachingConnectionFactory.java:344) ~[spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE] at $Proxy31.getTransacted(Unknown Source) ~[na:na] at org.springframework.jms.listener.AbstractMessageListenerContainer.commitIfNecessary(AbstractMessageListenerContainer.java:572) ~[spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE] at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:481) ~[spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE] at org.springframework.jms.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:439) ~[spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE] at org.springframework.jms.listener.SimpleMessageListenerContainer.processMessage(SimpleMessageListenerContainer.java:311) [spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE] at org.springframework.jms.listener.SimpleMessageListenerContainer$2.onMessage(SimpleMessageListenerContainer.java:287) [spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE] at org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:1230) [activemq-core-5.5.1.jar:5.5.1] at org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:134) [activemq-core-5.5.1.jar:5.5.1] at org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:205) [activemq-core-5.5.1.jar:5.5.1] at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:127) [activemq-core-5.5.1.jar:5.5.1] at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:48) [activemq-core-5.5.1.jar:5.5.1] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [na:1.7.0_04] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [na:1.7.0_04] at java.lang.Thread.run(Thread.java:722) [na:1.7.0_04] -- View this message in context: http://activemq.2283324.n4.nabble.com/Sugestions-how-to-listen-on-several-thousand-topics-with-spring-tp4653164p4653195.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.