Spring JMS监听器关闭问题

问题描述

启动项目时如果ActiveMQ没有打开,控制台一直报错:

WARN DefaultMessageListenerContainer:876 - Could not refresh JMS Connection for destination 'xxxxx' - retrying in 5000 ms. Cause: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused: connectuartzSchedulerThread" 

Exception in thread "org.springframework.jms.listener.DefaultMessageListenerContaine

原因是实现了MQ的监听,它会一直尝试连接MQ。

关闭方式

方式一

不引用bean实现或监听实现,这样不会启动数据监听,注释代码或者配置bean即可。

方式二

把MQ的配置单提取到一个Spring配置文件里,在导入这个文件的地方注释掉导入。

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:/context/boot/db.properties</value>
           <!-- <value>classpath:/context/boot/activemq.properties</value> -->
                <value>classpath:/context/boot/fileServer.properties</value> 
            </list>
        </property>
    </bean>




你可能感兴趣的:(spring,exception,JMS监听器关闭问题)