Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 2. Network Connectors
Abstract
Overview Link kopierenLink in die Zwischenablage kopiert!
Active consumers Link kopierenLink in die Zwischenablage kopiert!
Subscriptions Link kopierenLink in die Zwischenablage kopiert!
Propagation of subscriptions Link kopierenLink in die Zwischenablage kopiert!
ActiveMQ.Advisory.
advisorySupport attribute on the broker element is not set to false.
Network connector Link kopierenLink in die Zwischenablage kopiert!
networkConnector element, which is a child of the networkConnectors element.
Single connector Link kopierenLink in die Zwischenablage kopiert!
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 (
networkTTL) 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 (1) enables a message to make just one hop to a neighboring broker.Each time a message is forwarded across a network bridge, the receiving broker's ID is appended to an internal BrokerId array,BrokerPath. Comparison of thenetworkTTL's setting with the size ofBrokerPathenforces the configured number of hops.When messages fail to propagate as expected, you can useBrokerPath, which is exposed as a string property, to check the brokers that specific messages have traversed. Two methods are available, and both return a comma-separated list of broker IDs:- Browsing a message via JConsole, hawtio, or a JMS browser to check its
BrokerPathproperty - Programmatically via
getStringProperty("JMSActiveMQBrokerPath"); for example:((ActiveMQMessage)message1).getStringProperty(ActiveMQMessage.BROKER_PATH_PROPERTY). contains(localBroker.getBroker().getBrokerId().toString())
A list of returned broker IDs looks something like this:In this example, the first ID,[ID:jdoe-ThinkPad-T222s-35488-1985672254433-0:2, id_broker3, id_broker2]jdoe-ThinkPad-T222s-35488-1985672254433-0:2, is an embedded broker that has an automatically generated ID based on machine-name, and the second and third brokers were manually created with configured IDs.
Connectors in each direction Link kopierenLink in die Zwischenablage kopiert!
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 Link kopierenLink in die Zwischenablage kopiert!
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 Link kopierenLink in die Zwischenablage kopiert!
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 Link kopierenLink in die Zwischenablage kopiert!
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.