There are many benefits for using Virtual Destinations with ActiveMQ but basically you can forward messages from one JMS destination to many destinations (mixing queues and topics if you want), route messages to target destinations based on message headers (a.k.a broker-based message routing) and create highly-available load-balanced durable subscribers.
The example above is called Composite Destinations and the idea behind it is to map a Virtual Destinations to a hard-wired collection of physical destinations. From the JMS client application perspective there is nothing you'll need to change since all the configuration happens at the broker level.
So, let's look on what need to be done to work with Virtual and Composite Destinations with ActiveMQ.
The diagram above represents the idea of having producer P sending messages to a queue called CompositeQueue.q (it doesn't have to be called that way).
That queue is rooting messages to a topic called Topic.a and a queue called Queue.b.
All of the required configuration is done in the ActiveMQ XML configuration file. Below, there is snippet of the broker configuration file where the above example is configured.
<topic physicalName=“Topic.a" />
<queue physicalName=“Queue.b" />
The interesting thing here is that you can mix queues and topics without making any changes in the client code and this is not part of the JMS specification.
You can also extend that to use composite topics pretty much on the same way… Below you'll find a similar broker configuration to use Virtual Topics:
<queue physicalName="FOO" />
<topic physicalName="BAR" />
So, with a simple change in the ActiveMQ broker configuration you can dramatically change the way
the system works and extend it to your needs without changing the client application.