上午老板给了我一个小任务:解决他笔记本不连网的时候ActiveMQ无法启动的问题。我拔了网线后,启动ActiveMQ,报下面的错:
Broker. Reason: java.net.SocketException: error setting options
java.net.SocketException: error setting options
ERROR: java.lang.RuntimeException: Failed to execute start task. Reason:
org.springframework.beans.factory.BeanCreationE
xception: Error creating bean with name
'org.apache.activemq.xbean.XBeanBrokerService' defined in class path
resource [a
ctivemq.xml]: Initialization of bean failed; nested exception is
java.net.SocketException: error setting options
ERROR: java.lang.Exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'org.
apache.activemq.xbean.XBeanBrokerService' defined in class path resource
[activemq.xml]: Initialization of bean failed;
nested exception is java.net.SocketException: error setting options
网上搜索了下,发现是多播的问题,默认是允许多播的,可拔了网线后就只有一台机子了,所以多播就出问题了,我把activemq.xml里改了下:
<transportConnector name="openwire" uri="tcp://localhost:61616"/>
<transportConnector name="ssl" uri="ssl://localhost:61617"/>
<transportConnector name="stomp" uri="stomp://localhost:61613"/>
<transportConnector uri="http://localhost:8081"/>
<transportConnector uri="udp://localhost:61618"/>
</transportConnectors>
<networkConnectors>
<!-- by default just auto discover the other brokers -->
<!--networkConnector name="default-nc" uri="multicast://default"/-->
<!--networkConnector name="jjc" uri="static:(192.168.1.112)"/-->
<!--networkConnector name="506-02" uri="static:(192.168.1.114)"/-->
<networkConnector name="host1 and host2" uri="static://(tcp://host1:61616,tcp://host2:61616)" failover="true"/>
</networkConnectors>
拔掉网线,ok,ActiveMQ启动成功,哈哈,自以为搞定的时候,发现了一个古怪的问题,我把配置文件改回去,启动ActiveMQ,居然写的通信程序客户端之间还是可以进行通话,完全不受ActiveMQ前面报的错误的影响,真是让人哭笑不得。。。
估计是哪个开发人员开的玩笑,把这个warning写成了error吧,弄的我以为ActimveMQ没启动起来,实际上是已经启动了的。。。