2

我正在尝试创建一个由 2 个代理组成的 ActiveMQ 网络。我已经按照相关指南(http://activemq.apache.org/networks-of-brokers.html)中的描述完成了配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://activemq.org/config/1.0">

  <broker brokerName="receiver" persistent="false" useJmx="false">  
    <networkConnectors>
      <networkConnector uri="static:(tcp://host2:61616)"/>
    </networkConnectors>

    <persistenceAdapter>
      <memoryPersistenceAdapter/>
    </persistenceAdapter>

   <transportConnectors>
      <transportConnector uri="tcp://host1:61616"/>
    </transportConnectors>
  </broker>
</beans>

在上面的 XML 配置中,我假设一个网络代理在 host1 中运行,另一个在 host2 中运行。在 host2 上运行的代理将具有相反的值。JMS 无法启动,并且不会在日志文件中产生任何异常,出现的唯一消息是

INFO  | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1@3df78040: startup date [Tue Nov 22 20:54:53 CET 2011]; root of context hierarchy | org.apache.activemq.xbean.XBeanBrokerFactory$1 | main

有没有人设法建立一个由两个或多个 ActiveMQ 代理组成的网络?

4

2 回答 2

1

这对于 ActiveMQ 来说是很常见的事情。您可以在 ${ACTIVEMQ_HOME}/conf 目录(activemq-static-network-broker1.xml 和 activemq-static-network-broker2.xml)中获取一个示例配置来建立您的代理网络。

从我可以看到您的配置的名称空间是错误的。它应该是:

<beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:amq="http://activemq.apache.org/schema/core"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">

  <broker xmlns="http://activemq.apache.org/schema/core" brokerName="static-broker1">
    <!-- other stuff goes here -->
  </broker>

</beans>

需要注意的关键是这是一个 Spring 配置 (http://www.springframework.org/schema/beans),它具有定义 AMQ 代理 (http://activemq.apache.org/) 的 XBean 配置架构/核心)。

我也会回应 srodriguez 所说的,使用 0.0.0.0 作为你的 transportConnector 的主机名。

于 2011-11-25T14:43:29.150 回答
1

如果您使用的是静态代理网络,则需要指定形成代理网络的所有代理的 ip。

 <networkConnector name="HA Queue" uri="static:(tcp://host1:61616,tcp://host2:61616)"/>

另外,尝试以这种方式指定传输连接器:

    <transportConnectors>
       <transportConnector name="openwire" uri="tcp://0.0.0.0:61616" />
    </transportConnectors>
于 2011-11-24T06:39:02.147 回答