ActiveMQ forwarding from local broker to a remote broker [with unstable connection]
I have the following problem: I have several sites with a local ActiveMQ broker that forwards to a remote broker (in a datacenter). This connection is often unstable, and goes down several times a month for a few minutes or hours at a time.
Messages therefore need to wait on the local broker if the remote broker is not accessible at the moment.
I have the following ActiveMQ configuration:
<networkConnectors>
<networkConnector uri="static://(tcp://my-remote-broker:61616)"
name="myremotebroker" dynamicOnly="false"
conduitSubscriptions="true"
d开发者_开发知识库ecreaseNetworkConsumerPriority="false">
<!-- Exclude all destinations by default -->
<excludedDestinations>
<queue physicalName=">" />
<topic physicalName=">" />
</excludedDestinations>
<!-- Only forward these to our connection -->
<staticallyIncludedDestinations>
<topic physicalName="MySpecialTopic"/>
</staticallyIncludedDestinations>
</networkConnector>
</networkConnectors>
This forwards messages from the local broker (on topic MySpecialTopic), to the remote broker. This works when the connection is stable.
However, I tried temporarily disabling the internet connection, so that the local broker lost connection with the remote broker. At that point I sent a new message, which was enqueued on the local broker, but never arrived on the remote broker, even after the local broker re-connected!
Is there something in the ActiveMQ configuration that I am missing?
Thanks!
You are using a TOPIC, which is hit or miss. This means that sending a message while the connection is down WILL be lost, which is standard behaviour for a topic ( only subscribers that are subscribed at the time of the send of the message will receive the message). (http://activemq.apache.org/how-does-a-queue-compare-to-a-topic.html)
You should use a Queue if you want the remote Consumer to receive the message OR should setup your subscribers as durable subscribers to assure they will receive messages at all times.. (http://activemq.apache.org/how-do-durable-queues-and-topics-work.html)
精彩评论