【问题标题】:How to connect to ActiveMQ broker (stomp protocol,activemessaging) running in another Machine?如何连接到在另一台机器上运行的 ActiveMQ 代理(stomp 协议、activemessaging)?
【发布时间】:2011-03-31 23:07:18
【问题描述】:

基本上,我有 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"/>

提前致谢!

【问题讨论】:

    标签: activemq stomp activemessaging


    【解决方案1】:

    &lt;persistenceAdapter&gt; 元素之前将以下内容添加到代理 A 的配置中。然后代理将消息转发给代理 B:

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

    【讨论】:

      猜你喜欢
      • 2014-05-21
      • 2020-06-09
      • 2021-09-21
      • 2016-03-22
      • 2023-03-25
      • 2012-11-04
      • 1970-01-01
      • 2015-04-18
      • 1970-01-01
      相关资源
      最近更新 更多