此内容没有您所选择的语言版本。

7.2. Choosing the Shortest Route


Overview

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.

Connector configuration

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, “Network Connector for Choosing the Shortest Route” 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>
Copy to Clipboard Toggle word wrap
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 decreaseNetworkConsumerPriority on all of the connectors in your network, the brokers will not be able to accurately determine the shortest route. Some network connectors will not have the proper starting priority and will not reduce their priority as required.

Route priority and broker load

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.

Example

Figure 7.1, “Shortest Route in a Mesh Network” illustrates the effect of activating decreaseNetworkConsumerPriority in a broker network.

Figure 7.1. Shortest Route in a Mesh 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.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat