I face an exception and see the following getting logged when using the org.apache.activemq.pool.PooledConnectionFactory for producing messages to an AMQ Queue -
Caused by: java.lang.IllegalStateException: The session has already been closed
at org.apache.activemq.jms.pool.PooledSession.safeGetSessionHolder(PooledSession.java:482) ~[activemq-jms-pool-5.14.3.jar:5.14.3]
at org.apache.activemq.jms.pool.PooledSession.getInternalSession(PooledSession.java:382) ~[activemq-jms-pool-5.14.3.jar:5.14.3]
at org.apache.activemq.jms.pool.PooledSession.createQueue(PooledSession.java:197) ~[activemq-jms-pool-5.14.3.jar:5.14.3]
It also shows up as :
Caused by: javax.jms.IllegalStateException: The Session is closed
at org.apache.activemq.ActiveMQSession.checkClosed(ActiveMQSession.java:771) ~[activemq-client-5.14.3.jar:5.14.3]
at org.apache.activemq.ActiveMQSession.createQueue(ActiveMQSession.java:1329) ~[activemq-client-5.14.3.jar:5.14.3]
at org.apache.activemq.jms.pool.PooledSession.createQueue(PooledSession.java:197) ~[activemq-jms-pool-5.14.3.jar:5.14.3]
A few points to note: The parameter timeBetweenExpirationCheckMillis was added recently to the bean and the exceptions started showing up only after this change. My code uses the same connection pool for all consumers and producers. For AMQ interactions, I also use concurrent consumers in several places.
The beans for the connection and the pool are as follows:
<bean id="jmsPooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop" >
<property name="maxConnections" value="40" />
<property name="connectionFactory" ref="smiConnectionFactory" />
<property name="timeBetweenExpirationCheckMillis" value="300000" />
</bean>
<bean id="smiConnectionFactory" class="org.apache.activemq.ActiveMQSslConnectionFactory">
<property name="brokerURL" value="<ssl_protocol_broker>" />
<property name="userName" value="***********" />
<property name="password" value="***********" />
<property name="trustStore" value="************"/>
<property name="trustStorePassword" value="***********" />
<property name="keyStore" value="***********"/>
<property name="keyStorePassword" value="***********" />
<property name="optimizeAcknowledge" value="true" />
<property name="dispatchAsync" value="true" />
<property name="alwaysSessionAsync" value="true" />
<property name="useAsyncSend" value="true" />
<property name="watchTopicAdvisories" value="false" />
<property name="prefetchPolicy" ref="prefetchPolicy" />
</bean>
<bean id="prefetchPolicy" class="org.apache.activemq.ActiveMQPrefetchPolicy">
<property name="durableTopicPrefetch" value="2000" />
<property name="topicPrefetch" value="32766" />
<property name="queuePrefetch" value="0" />
</bean>
**UPDATE 1:**
Active MQ version : 5.14.5