开发者

How to get local ActiveMQ broker to "mirror" a queue on a remote ActiveMQ broker?

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.


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


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜