| ... Here is an example of two brokers networked together. The local broker contains the network connector configured with a dynamicallyIncludedDestination and the remote broker is configured with a CompositeTopic:
Code Block |
| language |
xml |
| title |
Local Broker |
|
<networkConnector uri="static:(tcp://host)">
<dynamicallyIncludedDestinations>
<topic physicalName="include.test.bar"/>
</dynamicallyIncludedDestinations>
</networkConnector> |
Code Block |
| language |
xml |
| title |
Remote Broker |
|
<compositeTopic name="include.test.bar" forwardOnly="false">
<forwardTo>
<queue physicalName="include.test.bar.forward" />
</forwardTo>
</compositeTopic > |
... First, we need to configure the broker to send advisory messages when consumers come online onto a destination that matches a Virtual Destination. In this case, a match is determined by the use of a Destination Filter will determines if a a destination forwards to another destination. The configuration on the remote broker should be updated to set the property useVirtualDestSubs to true to enable this.
Code Block |
| language |
xml |
| title |
Remote Broker |
|
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://activemq.org/config/1.0">
<broker name="broker1" useVirtualDestSubs="true">
.....
</broker>
</beans>
|
Second, we need to configure the network connector to listen for the new advisory messages:
Code Block |
| language |
xml |
| title |
Local Broker |
|
<networkConnector uri="static:(tcp://host)" useVirtualDestSubs="true">
<dynamicallyIncludedDestinations>
<topic physicalName="include.test.bar"/>
</dynamicallyIncludedDestinations>
</networkConnector> |
... Now let's consider the use case above where there is the same composite topic but no consumers on the queue.
Code Block |
| language |
xml |
| title |
Remote Broker |
|
<compositeTopic name="include.test.bar" forwardOnly="false">
<forwardTo>
<queue physicalName="include.test.bar.forward" />
</forwardTo>
</compositeTopic > |
There is a composite Topic configured on the remote broker and the local broker is networked to it. Even though we've enabled useVirtualDestSubs, messages wouldn't be forwarded to the remote broker unless a consumer comes online to the forwarded queue. This would cause messages to be dropped since they are sent to a topic. Sometimes it is desirable to have these messages forwarded based on the existence of the virtual destination. This only applies in the Queue case. For topics, messages should only be forwarded if there is a consumer or durable subscription.
Code Block |
| language |
xml |
| title |
Local Broker |
|
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://activemq.org/config/1.0">
<broker name="broker1" useVirtualDestSubs="true" useVirtualDestSubsOnCreation="true">
.....
</broker>
</beans>
|
With this configuration, when the Queue include.test.bar.forward is created, a Virtual Destination consumer advisory will be sent to the local broker so that it knows to forward messages based on the existence of the CompositeTopic and Queue existing. ... The above examples show how to configure a Composite destination but a Virtual Topic will also work. In the example below, a consumer on a Queue for a Virtual Topic will now cause demand and messages will be sent across a network.
Code Block |
| language |
xml |
| title |
Local Broker |
|
<networkConnector uri="static:(tcp://host)">
<dynamicallyIncludedDestinations>
<topic physicalName="VirtualTopic.>"/>
</dynamicallyIncludedDestinations>
</networkConnector> |
Code Block |
| language |
xml |
| title |
Remote Broker |
|
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://activemq.org/config/1.0">
<broker name="broker1" useVirtualDestSubs="true" >
.....
</broker>
</beans> |
... |