今天在玩Active MQ时,遇到一些小问题。现分享如下:
1. 下载ActiveMQ地址
http://activemq.apache.org/download.html
2. 解压缩到Windows系统中的如下目录
D:\software\develop\MQ\apache-activemq-5.15.4
3. 启动ActiveMQ
./activemq start
4. 出现如下error 信息
java.net.URISyntaxException: Illegal character in hostname at index 10: ws://{username}:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600
attempt: org.springframework.beans.factory.BeanCreationException: Error creatin
g bean with name 'org.apache.activemq.xbean.XBeanBrokerService#0' defined in cla
ss path resource [activemq.xml]: Invocation of init method failed; nested except
ion is java.net.URISyntaxException: Illegal character in hostname at index 10: w
s://Frank_ding:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600
ERROR: java.lang.RuntimeException: Failed to execute start task. Reason: java.la
ng.IllegalStateException: BeanFactory not initialized or already closed - call '
refresh' before accessing beans via the ApplicationContext
java.lang.RuntimeException: Failed to execute start task. Reason: java.lang.Ille
galStateException: BeanFactory not initialized or already closed - call 'refresh
' before accessing beans via the ApplicationContext
解决方案:
修改./conf/activemq.xml, 将transportConnector中的uri的默认0.0.0.0 修改为如下的127.0.0.1 。问题解决了。
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://127.0.0.1:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="amqp" uri="amqp://127.0.0.1:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="stomp" uri="stomp://127.0.0.1:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="mqtt" uri="mqtt://127.0.0.1:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="ws" uri="ws://127.0.0.1:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
5. 测试
http://127.0.0.1:8161/admin/
账户密码都是admin