如何让本地 ActiveMQ 代理“镜像”远程 ActiveMQ 代理上的队列?

发布于 2024-08-20 08:01:32 字数 626 浏览 3 评论 0原文

我有一个本地 ActiveMQ 代理,它位于不可靠的互联网连接上,还有一个位于可靠数据中心的远程 ActiveMQ 代理。我已经整理出“存储和转发”设置,以便在 Internet 连接可用时将传出消息发送到远程代理。仅此一项就很有效,但是当消息出站时。

然而,现在我必须反其道而行之。场景如下:

  1. 远程 ActiveMQ 代理中出现一条新消息。消息被放入特定的队列中。
  2. 几分钟后,本地 ActiveMQ 代理即可使用 Internet 连接。
  3. 然后,本地代理应该能够从远程代理中提取消息,并将其放入自己的本地队列中。
  4. 然后,本地消费者将能够看到该消息。

因此本质上,我需要本地代理成为远程队列的订阅消费者。我已经浏览了 ActiveMQ 文档,但在 .xml 配置文件中找不到有关如何执行此操作的任何内容。

这是我应该寻找的吗?请参阅:“ActiveMQ:JMS 到 JMS 桥”

任何建议和提示将不胜感激。

I have a local ActiveMQ broker which is on an unreliable internet connection, and also a remote ActiveMQ broker in a reliable datacenter. I have already sorted out a "store and forward" setup so that outgoing messages are sent to the remote broker when the Internet connection is available. That alone works great, but when messages are outbound.

However, now I have to do the reverse. Here is the scenario:

  1. A new message appears in the remote ActiveMQ broker. The message is put into a specific queue.
  2. In a few minutes, the Internet connection becomes available to the local ActiveMQ broker.
  3. The local broker should then be able to pull the message from the remote broker, and place it in its own local queue.
  4. Local consumers will then be able to see the message.

So in essence, I need the local broker to become a subscribed consumer to the remote queue. I have looked through the ActiveMQ documentations but I can't find anything yet about how to do this in the .xml configuration file.

Is this what I should be looking for? See: "ActiveMQ: JMS to JMS Bridge".

Any advice and tips would be highly appreciated.

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

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

发布评论

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

评论(2

没︽人懂的悲伤 2024-08-27 08:01:32

借助activemq代理网络,您可以轻松地进行存储和转发。 ( http://activemq.apache.org/networks-of-brokers.html )

如果您想要从本地到远程,则默认有效,如果您希望远程与本地对话,您应该:

A) 以与从本地到本地代理相同的方式建立从远程到本地代理的连接远程(使用故障转移传输,以便代理在连接丢失和恢复后重新连接。我们一直这样做,效果很好)

B)将您已有的连接从本地双工连接到远程双工(查看双工 uri 参数在上面的链接上)。

duplex false 如果为 true,则网络连接将用于生成和使用消息。当集线器位于防火墙后面等情况下,这对于集线器和辐射方案很有用。

例子:

 <networkConnector name="REMOTE" uri="static://(tcp://IP_OR_REMOTE_HOST:61616)" userName="system" password="manager" duplex="true"/>

With activemq network of brokers, you can easily do the store and forward. ( http://activemq.apache.org/networks-of-brokers.html )

If you want from local to remote, the default works, if you want remote to talk back to local, you should either:

A) Make a connection from the remote to the local broker in the same way you did from local to remote ( use the failover transport so the brokers reconnect after loss and restore of connection. We do this all the time and it works great)

B) Make the connection you already have from local to remote duplex ( take a look at the duplex uri parameter on the link above).

duplex false if true, a network connection will be used to both produce AND Consume messages. This is useful for hub and spoke scenarios when the hub is behind a firewall etc.

Example:

 <networkConnector name="REMOTE" uri="static://(tcp://IP_OR_REMOTE_HOST:61616)" userName="system" password="manager" duplex="true"/>
高冷爸爸 2024-08-27 08:01:32

我使用 JMS 到 JMS 桥使其工作。请参阅下面的相关配置。

不过我看到了另一个潜在的问题。在远程 ActiveMQ 代理上,“排队消息”似乎只是停留在那里。我希望它们被自动删除。

... snip snip
    <jmsBridgeConnectors>
        <jmsTopicConnector
          outboundTopicConnectionFactory="#remoteFactory">
          <inboundTopicBridges>
            <inboundTopicBridge inboundTopicName="jms/TestTopic1" localTopicName="jms/TestTopicResult" />
          </inboundTopicBridges>
        </jmsTopicConnector>
    </jmsBridgeConnectors>

</broker>
<bean id="remoteFactory"
    class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="tcp://x.x.x.x:61616" />
</bean>
... snip snip

I made it work using JMS to JMS Bridge. See relevant config below.

I see another potential problem though. On the remote ActiveMQ broker, the "enqueued messages" seem to just linger there. I'd prefer them to be automatically deleted.

... snip snip
    <jmsBridgeConnectors>
        <jmsTopicConnector
          outboundTopicConnectionFactory="#remoteFactory">
          <inboundTopicBridges>
            <inboundTopicBridge inboundTopicName="jms/TestTopic1" localTopicName="jms/TestTopicResult" />
          </inboundTopicBridges>
        </jmsTopicConnector>
    </jmsBridgeConnectors>

</broker>
<bean id="remoteFactory"
    class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="tcp://x.x.x.x:61616" />
</bean>
... snip snip
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文