Chapter 7. Optimizing Routes


Abstract

It is possible, depending on your network's topology, that a message will multiple routes through the network. Red Hat JBoss A-MQ allows you to configure the network to reduce the number of alternate routes and choose the optimum route.
In network topologies such as a hub-and-spoke or a tree there exists a unique route between any two brokers. For topologies, such as a mesh or a complete graph, it is possible to have multiple routes between any two brokers. In such cases, you may need simplify the routing behavior, so that an optimum route is preferred by the network.
Red Hat JBoss A-MQ provides two configuration settings that work in conjunction to refine routing behavior:
  • decreaseNetworkConsumerPriority—deprecates the priority of a network connector based on the number of hops from the message's origin so that messages are routed along the shortest route
  • suppressDuplicateQueueSubscriptions—suppresses duplicate subscriptions from intermediary brokers so that alternative paths are reduced
Important
To be most effective these properties should be set on all of the network connectors in the network of brokers.

7.1. 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>
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

circular six 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.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.