Cluster Setup (N-Node)
This guide explains how to configure a JMS Bridge cluster with N broker nodes using static connectors in ActiveMQ Artemis. This approach is ideal for controlled deployments with known broker endpoints.
Why Cluster?
Section titled “Why Cluster?”A cluster enables:
- Load balancing of messages across broker nodes
- Failover handling if a node goes down
- Horizontal scalability for high-throughput systems
- Message redistribution for active consumers
Architecture (N Nodes)
Section titled “Architecture (N Nodes)”Each broker node connects to every other node via TCP connectors.
Broker-1 <----> Broker-2 | | | | Broker-3 <----> ... <----> Broker-N
This forms a full-mesh topology using static TCP connectors.
Configuration
Section titled “Configuration”1. Define Connectors (per node)
Section titled “1. Define Connectors (per node)”Each node must define a self
connector and static connectors for the other N–1 nodes.
Example for Broker-1:
<connectors> <connector name="self">tcp://broker1-host:61616</connector> <connector name="broker2">tcp://broker2-host:61617</connector> <connector name="broker3">tcp://broker3-host:61618</connector> <!-- Add additional connectors up to broker-N --></connectors>
Do not include
self
in the static connectors list.
2. Define Cluster Connection
Section titled “2. Define Cluster Connection”Use a <cluster-connection>
to link nodes. Example for Broker-1:
<cluster-connections> <cluster-connection name="jms-cluster"> <connector-ref>self</connector-ref> <retry-interval>1000</retry-interval> <message-load-balancing>STRICT</message-load-balancing> <max-hops>1</max-hops> <static-connectors> <connector-ref>broker2</connector-ref> <connector-ref>broker3</connector-ref> <!-- Up to broker-N --> </static-connectors> </cluster-connection></cluster-connections>
Repeat on every broker, changing the self
connector and static-connectors
accordingly.
Enable Message Redistribution
Section titled “Enable Message Redistribution”Set redistribution so messages are forwarded to nodes with active consumers:
<address-settings> <address-setting match="#"> <redistribution-delay>0</redistribution-delay> </address-setting></address-settings>
Testing the Cluster
Section titled “Testing the Cluster”- Start all broker nodes.
- Send a message to any node.
- Consume it from another node connected to the same queue.
Best Practices
Section titled “Best Practices”- Use unique ports for each broker (e.g., 61616, 61617, …).
- Use meaningful connector names for clarity.
- Keep cluster topology symmetric (every node knows all others).
- Use
message-load-balancing=STRICT
to optimize routing.
Sample Connector Generator (Optional)
Section titled “Sample Connector Generator (Optional)”To quickly generate <connector-ref>
blocks for N nodes:
for i in $(seq 2 20); do echo "<connector-ref>broker$i</connector-ref>"done