springboot中activemq报错
报错内容 :Caused by: javax.jms.JMSException: Could not connect to broker URL: tcp://127.0.0.1:61606. Reason: java.net.ConnectException: Connection refused: connect
报错原因:有两种情况,
第一种,springboot项目中有开发者配置的activemq.xml,项目启动时会使用此配置文件中。
第二种,springboot项目中没有开发者配置的activemq.xml
解决方法:
①第一种情况:关闭本地activemq,最好将本地mq的openwire的端口,改成与springboot不重复的端口。
·打开apache-activemq-5.14.4\conf文件夹下的activemq.xml配置文件
·找到以下内容,将springboot配置文件的activemq端口改成61616
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
②第二种情况 :确保activemq已运行,openwire端口已在监听,springboot配置的端口与openwire端口一致
补充:
如果您需要查找用户名和密码,则请查找该配置文件中列出的 <simpleAuthenticationPlugin>
元素。元素如下所示:
<plugins>
<simpleAuthenticationPlugin anonymousAccessAllowed="true">
<users>
<authenticationUser username="admin" password="admin" groups="admins,mygroup"/>
<authenticationUser username="user" password="password" groups="users"/>
</users>
</simpleAuthenticationPlugin>
</plugins>