Spring ActiveMQ Caused By: javax.jms.IllegalStateException: Connection closed

根据 http://www.cnblogs.com/yshyee/p/7448808.html 进行JMS操作时,发送跟监听放到不同的项目中进行时,出现以下异常信息:

org.springframework.jms.IllegalStateException: Connection closed; nested exception is javax.jms.IllegalStateException: Connection closed
        at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:279)
        at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:169)
        at org.springframework.jms.core.JmsTemplate.executeLocal(JmsTemplate.java:987)
        at org.springframework.jms.core.JmsTemplate.sendAndReceive(JmsTemplate.java:913)
        at org.springframework.jms.core.JmsTemplate.sendAndReceive(JmsTemplate.java:904)
        Truncated. see log file for complete stacktrace
Caused By: javax.jms.IllegalStateException: Connection closed
        at org.apache.activemq.jms.pool.PooledConnection.assertNotClosed(PooledConnection.java:206)
        at org.apache.activemq.jms.pool.PooledConnection.start(PooledConnection.java:94)
        at org.springframework.jms.connection.SingleConnectionFactory$SharedConnectionInvocationHandler.localStart(SingleConnectionFactory.java:632)
        at org.springframework.jms.connection.SingleConnectionFactory$SharedConnectionInvocationHandler.invoke(SingleConnectionFactory.java:569)
        at com.sun.proxy.$Proxy189.start(Unknown Source)
        Truncated. see log file for complete stacktrace

解决方法:

修改 amqConnectionFactory配置如下:

    <!-- ActiveMQ 连接工厂 -->
    <bean id="amqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL">
            <value>${amq.broker.url}</value>
        </property>
        <property name="userName">
            <value>${amq.username}</value>
        </property>
        <property name="password">
            <value>${amq.password}</value>
        </property>
    </bean>

 

posted @ 2017-09-11 18:02  yshy  阅读(1066)  评论(0编辑  收藏  举报