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

发布于 2024-09-15 05:06:19 字数 3646 浏览 9 评论 0原文

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

提前致谢!

Basically, I have 2 MQs running on different machines(ubuntu).
I need them to be able to communicate with one another.

I have my broker.yml,on machine A, like this;

development:

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

test:

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

production:

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

and broker.yml on machine B like this;

development:

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

test:

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

production:

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

How do i configure apache-activemq/conf/activemq.xml so that I can make machine A pass messsage to machine B.

Right now, my activemq.xml looks like this:

<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"/>

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

剩余の解释 2024-09-22 05:06:19

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

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

Add the following to Broker A's config right before the <persistenceAdapter> element. The broker will then forward messages to Broker B:

<networkConnectors>
    <networkConnector uri="static:(tcp://--IP of machine B here--:61616)"/>
</networkConnectors>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文