Chapter 36. Clusters

36.1. Clusters Overview

HornetQ clusters allow groups of HornetQ servers to be grouped together in order to share message processing load. Each active node in the cluster is an active HornetQ server which manages its own messages and handles its own connections. A server must be configured to be clustered, you will need to set the clustered element in <JBOSS_HOME>/jboss-as/server/<PROFILE>/deploy/hornetq/hornetq-configuration.xml to true (false by default).

Important

You must enable clustering on those profiles that already contain a /hornetq directory, which is all profiles excluding Minimal and Web. Those profiles not containing a /hornetq directory do not natively contain the correct components to support a cluster.
The cluster is formed by each node declaring cluster connections to other nodes in <JBOSS_HOME>/jboss-as/server/<PROFILE>/deploy/hornetq/hornetq-configuration.xml. When a node forms a cluster connection to another node, internally it creates a core bridge (as described in Chapter 34, Core Bridges) connection between it and the other node, this is done transparently behind the scenes - you do not need to declare an explicit bridge for each node. These cluster connections allow messages to flow between the nodes of the cluster to balance load.
Nodes can be connected together to form a cluster in many different topologies. Common topologies are discussed later in this chapter.
Client side load balancing is discussed, where client connections can be balanced across the nodes of the cluster. Message redistribution where HornetQ will redistribute messages between nodes to avoid starvation is also covered.
Another important part of clustering is server discovery where servers can broadcast their connection details so clients or other servers can connect to them with the minimum of configuration.

Warning

If you start a JBoss Enterprise Application Platform instance with a HornetQ server bound to 'localhost', the HornetQ instance could form a cluster with another HornetQ instance on the same network. Binding to localhost does not provide cluster isolation for HornetQ servers.
To correctly isolate clusters, refer to Section 36.2.1, “Broadcast Groups” to correctly configure the broadcast and discovery addresses of each server.