PooledConnectionFactory-会话已经关闭

时间:2019-02-15 05:56:58

标签: apache-camel jms activemq illegalstateexception spring-camel

我遇到一个异常,使用org.apache.activemq.pool.PooledConnectionFactory生成向AMQ队列发送消息时看到以下记录-

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]

它也显示为:

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]

需要注意的几点: 参数timeBetweenExpirationCheckMillis是最近添加到Bean的,并且只有在进行此更改之后,才会开始显示异常。 我的代码为所有使用者和生产者使用相同的连接池。 对于AMQ交互,我还在多个地方使用并发使用者。

用于连接和池的bean如下:

<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


0 个答案:

没有答案