如何连接到另一台机器上运行的ActiveMQ代理(stomp协议,activemessaging)?

时间:2010-08-19 06:33:53

标签: activemq stomp activemessaging

基本上,我有2个MQ在不同的机器上运行(ubuntu)。 我需要他们能够彼此沟通。

我有我的broker.yml,在机器A上,就像这样;

发展:

adapter: stomp
login: ""
passcode: ""
host: localhost
port: 61613
reliable: true
reconnectDelay: 5
foo:
    adapter: stomp
    login: ""
    passcode: ""
    host: --IP of machine B here--
    port: 61613
    reliable: true
    reconnectDelay: 5

试验:

adapter: stomp
login: ""
passcode: ""
host: localhost
port: 61613
reliable: true
reconnectDelay: 5
foo:
    adapter: stomp
    login: ""
    passcode: ""
    host: --IP of machine B here--
    port: 61613
    reliable: true
    reconnectDelay: 5

生产:

adapter: stomp
login: ""
passcode: ""
host: localhost
port: 61613
reliable: true
reconnectDelay: 5
foo:
    adapter: stomp
    login: ""
    passcode: ""
    host: --IP of machine B here--
    port: 61613
    reliable: true
    reconnectDelay: 5
机器B上的

和broker.yml就像这样;

发展:

adapter: stomp
login: ""
passcode: ""
host: localhost
port: 61613
reliable: true
reconnectDelay: 5

试验:

adapter: stomp
login: ""
passcode: ""
host: localhost
port: 61613
reliable: true
reconnectDelay: 5

生产:

adapter: stomp
login: ""
passcode: ""
host: localhost
port: 61613
reliable: true
reconnectDelay: 5

如何配置apache-activemq / conf / activemq.xml以便我可以将机器A传递给机器B的消息。

现在,我的activemq.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">

<!-- Allows us to use system properties as variables in this configuration file -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <value>file:${activemq.base}/conf/credentials.properties</value>
    </property>      
</bean>

<!-- 
    The <broker> element is used to configure the ActiveMQ broker. 
-->
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.base}/data" destroyApplicationContextOnStop="true">


    <destinationPolicy>
        <policyMap>
          <policyEntries>
            <policyEntry topic=">" producerFlowControl="true" memoryLimit="1mb">
              <pendingSubscriberPolicy>
                <vmCursor />
              </pendingSubscriberPolicy>
            </policyEntry>
            <policyEntry queue=">" producerFlowControl="true" memoryLimit="1mb">                  
            </policyEntry>
          </policyEntries>
        </policyMap>
    </destinationPolicy> 



    <managementContext>
        <managementContext createConnector="false"/>
    </managementContext>


    <persistenceAdapter>
        <kahaDB directory="${activemq.base}/data/kahadb"/>
    </persistenceAdapter>



    <transportConnectors>               
  <transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>  
  <transportConnector uri="stomp://localhost:61613"/>
    </transportConnectors>

</broker>
<import resource="jetty.xml"/>

提前致谢!

1 个答案:

答案 0 :(得分:1)

<persistenceAdapter>元素之前将以下内容添加到Broker A的配置中。然后,经纪人将消息转发给经纪人B:

<networkConnectors>
    <networkConnector uri="static:(tcp://--IP of machine B here--:61616)"/>
</networkConnectors>