Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 2. Network Connectors
Abstract
Overview Copier lienLien copié sur presse-papiers!
Active consumers Copier lienLien copié sur presse-papiers!
Subscriptions Copier lienLien copié sur presse-papiers!
Propagation of subscriptions Copier lienLien copié sur presse-papiers!
ActiveMQ.Advisory.
advisorySupport attribute on the broker element is not set to false.
Network connector Copier lienLien copié sur presse-papiers!
networkConnector element, which is a child of the networkConnectors element.
Single connector Copier lienLien copié sur presse-papiers!
Figure 2.1. Single Connector
Example 2.1. Single connector configuration
<beans ...>
<broker xmlns="http://activemq.apache.org/schema/core"
brokerName="brokerA" brokerId="A" ... >
...
<networkConnectors>
<networkConnector name="linkToBrokerB"
uri="static:(tcp://localhost:61002)"
networkTTL="3"
/>
</networkConnectors>
...
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61001"/>
</transportConnectors>
</broker>
</beans>
networkConnector element in the preceding example sets the following basic attributes:
name- Identifies this network connector instance uniquely (for example, when monitoring the broker through JMX). If you define more than one
networkConnectorelement on a broker, you must set the name in order to ensure that the connector name is unique within the scope of the broker. uri- The discovery agent URI that returns which brokers to connect to. In other words, broker A connects to every transport URI returned by the discovery agent.In the preceding example, the static discovery agent URI returns a single transport URI,
tcp://localhost:61002, which refers to a port opened by one of the transport connectors on broker B. networkTTL- The network time-to-live (TTL) attribute specifies the maximum number of hops that a message can make through the broker network. It is almost always necessary to set this attribute, because the default value of 1 would only enable a message to make a single hop to a neighboring broker.
Connectors in each direction Copier lienLien copié sur presse-papiers!
Figure 2.2. Connectors in Each Direction
Example 2.2. Two way connector
<beans ...>
<broker xmlns="http://activemq.apache.org/schema/core"
brokerName="brokerB" brokerId="B"... >
...
<networkConnectors>
<networkConnector name="linkToBrokerA"
uri="static:(tcp://localhost:61001)"
networkTTL="3" />
</networkConnectors>
...
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61002" />
</transportConnectors>
</broker>
</beans>
Duplex connector Copier lienLien copié sur presse-papiers!
Figure 2.3. Duplex Connector
duplex attibute to true. For example, to make the network connector on broker A a duplex connector, you can configure it as follows:
Example 2.3. Duplex connector configuration
<networkConnectors>
<networkConnector name="linkToBrokerB"
uri="static:(tcp://localhost:61002)"
networkTTL="3"
duplex="true" />
</networkConnectors>
Multiple connectors Copier lienLien copié sur presse-papiers!
Figure 2.4. Multiple Connectors
networkConnector element for each connector and specify a unique name for each connector, as follows:
<networkConnectors>
<networkConnector name="link01ToBrokerB"
uri="static:(tcp://localhost:61002)"
networkTTL="3"
/>
<networkConnector name="link02ToBrokerB"
uri="static:(tcp://localhost:61002)"
networkTTL="3"
/>
<networkConnector name="link03ToBrokerB"
uri="static:(tcp://localhost:61002)"
networkTTL="3"
/>
</networkConnectors>
- Spreading the load amongst multiple connections.
- Defining separate configuration for topics and queues. That is, you can configure one network connector to transmit queue subscriptions only and another network connector to transmit topic subscriptions only.
Conduit subscriptions Copier lienLien copié sur presse-papiers!
Figure 2.5. Conduit Subscriptions
t, which gives rise to the subscriptions, C1:t and C2:t in broker B. Both of these subscriptions propagate automatically from broker B to broker A. Because broker A has conduit subscriptions enabled, its network connector consolidates the duplicate subscriptions, C1:t and C2:t, into a single subscription, B:t. Now, if a message on topic t is sent to broker A, broker A sends a single copy of the message to broker B, to honor the conduit subscription, B:t. Broker B then sends a copy of the message to each consumer, to honor the topic subscriptions, C1:t and C2:t.
B:C1:t and B:C2:t, would be registered in broker A. Now, if a message on topic t is sent to broker A, broker A would send two copies of the message to broker B, to honor the topic subscriptions, B:C1:t and B:C2:t. Broker B would then send two copies of the message to each consumer, to honor the topic subscriptions, C1:t and C2:t. In other words, each consumer would receive the topic message twice.
conduitSubscriptions attribute to false on the networkConnector element. See Section 9.1, “Balancing Consumer Load” for more details.