Reputation: 808
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:
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.
Upvotes: 2
Views: 5683
Reputation: 664
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"/>
Upvotes: 4
Reputation: 808
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
Upvotes: 1