If you reached here, you might have
already checked few very confusing paragraphs about Mirror queues in ActiveMQ.
Mirror Queues are disabled by default. To enable them, you
have to following settings in activemq.xml
<destinationInterceptors>
<mirroredQueue copyMessage = "true"
postfix="" prefix="MIRROR."/>
<virtualDestinationInterceptor>
<virtualDestinations>
<virtualTopic
name="MIRROR.TEST.>"
prefix="MIR.>." selectorAware="false"/>
</virtualDestinations>
</virtualDestinationInterceptor>
</destinationInterceptors>
Out of above: “<mirroredQueue copyMessage =
"true" postfix="" prefix="MIRROR."/>” is
actually responsible for enabling Mirror Queues.
How ActiveMQ Handles Mirror Queues:
1.
When you enable Mirror Queues, with say prefix
as “MIRROR.”, for every queue in the broker one Topic will be created with
MIRROR. Prefix.
2.
Now to receive a message from this Topic,
Virtual Destinations can be used. More about Virtual Destination can be found here.
Working Example:
Let’s consider
above configuration for prefix for Mirror queues and Virtual Destinations.
1.
Create a queue: TEST.QUEUE
2.
With above settings, Mirror Topic is
automatically created as : MIRROR.TEST.QUEUE
3.
Create Virtual Topic Consumer : MIR.COPY.MIRROR.TEST.QUEUE
a.
MIR – Defined Virtual Topic Interceptor
b.
COPY – Name of the Consumer
c.
MIRROR.TEST.QUEUE
– is a Topic Name
4.
Send a test message to TEST.QUEUE, same message
will appear in MIR.COPY.MIRROR.TEST.QUEUE.
This is complete setting of Mirror Queues.
Problems:
1.
Mirror Topics will be created for Every Queue in
the broker
2.
As broker has to track each message from the
queue and copy it to topic, further to virtual destination, broker may face
performance problem depending on load.
No comments:
Post a Comment