您的位置:首页 > 其它

activeMQ networkConnectors

2016-04-20 16:39 197 查看
最近在学习activeMQ,看的是 activemq in Action这本书,当读到4.5章节Network connnectors时遇到了一点问题,折腾了几天才解决,写下心得

书中看到这里:

activemq xbean:src/main/resources/org/apache/activemq/book/ch4/brokerA.xml

当我打开cmd,运行此命令时没有报错,一切正常,但当我启动consumer时,却找不到61617的监听,但是brokerA.xml中明明已经配置

<!-- The transport connectors ActiveMQ will listen to -->

<transportConnectors>

<transportConnector name="openwire" uri="tcp://localhost:61616" />

</transportConnectors>

<networkConnectors>

<networkConnector uri="static:(tcp://localhost:61617)" />

</networkConnectors>

什么问题呢?难道是自己指定的xbean的路径有问题,所以故意在brokerA.xml中再加载一个

<transprotConnector name="openwire" uri="tcp://localhost;61616"/>

如果能加载到,那么这两个bean相同,应该会报错,但是还是成功启动,没有任何错误,那肯定就是根本没有加载到这个配置文件了,反复试验,用各种方法都加载不到。网上查看资料也找不到对应的。最后本人怀疑起一件事情:

书中的原代码用的是activeMQ5.3.2的,本人用的是activeMQ5.13的,会不会是最新的activeMQ已经把xbean这个命令去掉了,索性下载一个5.4的,再加载,报错。起初我认为最新的5.13应该是不支持xbean这种加载方法。然后心里面还是不踏实,觉得如果不支持xbean这种方法的加载,只能默认加载activemq.xml那启不是activemq的一种倒退,查阅资料,还是解不开问题。等到第二天,我又下载了5.10这个版本,还是不行,仍然不能下载用xbean加载到别的配置文件。

难道我只能用5.4这个版本,要知道这个版本对应的spring可是2.X,现在的spring基本都是3.X,仍然心有不甘。

最后登陆acitveMQ的官网http://activemq.apache.org/getting-started.html

看到上面启动MQ的方法是这样的

Starting ActiveMQ

There now follows instructions on how to
run the ActiveMQ Message Broker.

On Windows:

From a console window, change to the installation directory and run
ActiveMQ
:

where
activemq_install_dir
is the directory in which ActiveMQ was installed, e.g.,
c:\Program Files\ActiveMQ-5.x
.

Then type:

NOTE: Working directories get created relative to the current directory. To create working directories in the proper place, ActiveMQ must be launched from its home/installation directory.

而本人用的是64们操作系统,一直认为是bin\win64\activemq

换成这种方法,cmd里只是显示很多内容,根本没有启动,加上xbean仍然启动不了,这是为什么呢,难道官网介绍也有错误,想了下,这些5.x应该有新命令,

浏览了这里 http://activemq.apache.org/version-5-getting-started.html

On Windows

From a console window, change to the installation directory and run
ActiveMQ
:

where
activemq_install_dir
is the directory in which ActiveMQ was installed, e.g.,
c:\Program Files\ActiveMQ-5.x
.

Then type (depending on ActiveMQ version):

ActiveMQ 5.10 onwards

ActiveMQ 5.9 or older

恍然大悟,原来新的MQ应该是用activemq start来启动的,再加了xbean,成功启动

但是错误除了重复的bean外,还显示找不到networkConnectors这个标记?

为什么呢?

网上查看了资料,原文如下:

I ran into the same problem. The networkConnectors need to be first in the XML declaration.

调整了下顺序,果然成功运行了!



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: