In indeterminate networks, it is typically preferable for messages to take the shortest route. This reduces the time for the message to reach its destination, reduces the chances of the message being caught in a broker failure, and reduces the load on the network. In general, sending messages along to the nearest possible consumer maximizes the effectiveness of the broker network.
This is accomplished by configuring all of the connectors in your network to generate route priorities that automatically lowers the route's priority for each network connector it must traverse In this way the broker's can determine the shortest route between a message's producer and its consumer. In most cases, the broker will use the shortest route. However, if the shortest route is under heavy load, the broker will divert it to the next shortest route.
To ensure that the shortest route is preferred, you need to configure
all of the network connectors in the network to create priority
profiles for each of the possible routes through the network. This is done by setting the
networkConnetor
element's
decreaseNetworkConsumerPriority
attribute to
true
.
Example 7.1 shows a network connector configured to determine the shortest route.
Example 7.1. Network Connector for Choosing the Shortest Route
<networkConnectors> <networkConnector name="linkToBrokerB" uri="static:(tcp://localhost:61002)" networkTTL="3" decreaseNetworkConsumerPriority="true" /> </networkConnectors>
When decreaseNetworkConsumerPriority
is set to
true
, the route priority is determined as follows:
Local consumers (attached directly to the broker) have a priority of
0
.Network subscriptions have an initial priority of
-5
.The priority of a network subscription is reduced by
1
for every network hop that it traverses.
![]() | Important |
---|---|
If you choose not to enable |
A broker prefers to send messages to the subscription with the highest priority. However, if the prefetch buffer for that subscription is full, the broker will divert messages to the subscription with the next highest priority.
If multiple subscriptions have the same priority, the broker distributes messages equally between those subscriptions.
Figure 7.1 illustrates the effect of
activating decreaseNetworkConsumerPriority
in a broker
network.
In this network, there are three alternative routes connecting producer P to consumer
C1: PBAFEC1
(three broker hops), PBEC1
(one broker hop), and
PBCDEC1
(three broker hops). When
decreaseNetworkConsumerPriority
is enabled, the route
PBEC1
has highest priority, so messages from P to C1 are sent along this
route unless connector BE
's prefetch buffer is full. In the case where
connector BE
's prefetch buffer is full messages will be sent to route
PBAFEC1
and route PBCDEC1
on an alternating basis.