Skip to content

Commit 5b3258e

Browse files
renamed star mirror as mesh mirror, added diagram
With the help of Claude that setup the diagram
1 parent 05b4f99 commit 5b3258e

18 files changed

Lines changed: 141 additions & 28 deletions

File tree

examples/features/broker-connection/ha-with-star-mirror/clients-layout.conf renamed to examples/features/broker-connection/ha-with-mesh-mirror/clients-layout.conf

File renamed without changes.

examples/features/broker-connection/ha-with-star-mirror/pom.xml renamed to examples/features/broker-connection/ha-with-mesh-mirror/pom.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ under the License.
2727
<version>2.54.0-SNAPSHOT</version>
2828
</parent>
2929

30-
<artifactId>ha-with-star-mirror</artifactId>
30+
<artifactId>ha-with-mesh-mirror</artifactId>
3131
<packaging>jar</packaging>
32-
<name>Apache Artemis Example - HA with Star Mirror</name>
32+
<name>Apache Artemis Example - HA with Mesh Mirror</name>
3333

3434
<properties>
3535
<activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
@@ -129,7 +129,7 @@ under the License.
129129
<dependencies>
130130
<dependency>
131131
<groupId>org.apache.artemis.examples.broker-connection</groupId>
132-
<artifactId>ha-with-star-mirror</artifactId>
132+
<artifactId>ha-with-mesh-mirror</artifactId>
133133
<version>${project.version}</version>
134134
</dependency>
135135
</dependencies>
@@ -188,7 +188,7 @@ under the License.
188188
<goal>runClient</goal>
189189
</goals>
190190
<configuration>
191-
<clientClass>org.apache.artemis.jms.example.HAWithStarMirrorExample</clientClass>
191+
<clientClass>org.apache.artemis.jms.example.HAWithMeshMirrorExample</clientClass>
192192
<args>
193193
<param>${basedir}/target/server0</param>
194194
<param>${basedir}/target/server1</param>
@@ -200,7 +200,7 @@ under the License.
200200
<dependencies>
201201
<dependency>
202202
<groupId>org.apache.artemis.examples.broker-connection</groupId>
203-
<artifactId>ha-with-star-mirror</artifactId>
203+
<artifactId>ha-with-mesh-mirror</artifactId>
204204
<version>${project.version}</version>
205205
</dependency>
206206
</dependencies>
@@ -233,7 +233,7 @@ under the License.
233233
<dependencies>
234234
<dependency>
235235
<groupId>org.apache.artemis.examples.broker-connection</groupId>
236-
<artifactId>ha-with-star-mirror</artifactId>
236+
<artifactId>ha-with-mesh-mirror</artifactId>
237237
<version>${project.version}</version>
238238
</dependency>
239239
</dependencies>
@@ -262,7 +262,7 @@ under the License.
262262
<dependencies>
263263
<dependency>
264264
<groupId>org.apache.artemis.examples.broker-connection</groupId>
265-
<artifactId>ha-with-star-mirror</artifactId>
265+
<artifactId>ha-with-mesh-mirror</artifactId>
266266
<version>${project.version}</version>
267267
</dependency>
268268
</dependencies>
@@ -291,7 +291,7 @@ under the License.
291291
<dependencies>
292292
<dependency>
293293
<groupId>org.apache.artemis.examples.broker-connection</groupId>
294-
<artifactId>ha-with-star-mirror</artifactId>
294+
<artifactId>ha-with-mesh-mirror</artifactId>
295295
<version>${project.version}</version>
296296
</dependency>
297297
</dependencies>

examples/features/broker-connection/ha-with-star-mirror/readme.md renamed to examples/features/broker-connection/ha-with-mesh-mirror/readme.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
1-
# High Availability with Star Mirror and Distributed Locks
1+
# High Availability with Mesh Mirror and Distributed Locks
22

3-
This example demonstrates how to achieve high availability (HA) using star topology mirroring combined with distributed locks from the Lock Coordinator feature. The distributed locks ensure that only one broker accepts client connections at a time, providing automatic failover without split-brain scenarios across three brokers.
3+
This example demonstrates how to achieve high availability (HA) using mesh topology mirroring combined with distributed locks from the Lock Coordinator feature. The distributed locks ensure that only one broker accepts client connections at a time, providing automatic failover without split-brain scenarios across three brokers.
44

55
## Overview
66

77
This example configures three brokers (server0, server1, and server2) that:
8-
- Mirror all messaging operations to each other using broker connections in a star topology
8+
- Mirror all messaging operations to each other using broker connections in a mesh topology
99
- Share a distributed file-based lock to coordinate which broker accepts client connections
1010
- Automatically failover client connections when the active broker fails
1111
- Use lock coordinator on broker connections to ensure mirroring only happens when the broker is active
1212

13+
## Topology Diagram
14+
15+
![Mesh Topology](src/main/resources/images/mesh-topology.svg)
16+
17+
**Key Points:**
18+
- Only Server 0 (holding the lock) actively mirrors data to Server 1 and Server 2 (solid blue arrows)
19+
- Server 1 and Server 2 have passive broker connections (dashed gray arrows - not actively mirroring)
20+
- When Server 0 fails, Server 1 or Server 2 acquires the lock and becomes active
21+
- The new active server's connections become active and start mirroring
22+
1323
## How It Works
1424

15-
### Star Topology Mirroring Configuration
25+
### Mesh Topology Mirroring Configuration
1626

1727
All three brokers are configured with mirroring to the other two brokers using AMQP broker connections. The key feature is using the **lock-coordinator attribute on broker connections**, which ensures that mirroring only happens when the broker holding the lock is active.
1828

@@ -54,7 +64,7 @@ All three brokers are configured with mirroring to the other two brokers using A
5464
</broker-connections>
5565
```
5666

57-
This ensures that messages, queues, and other operations are replicated across all three brokers in a star topology.
67+
This ensures that messages, queues, and other operations are replicated across all three brokers in a mesh topology.
5868

5969
### Lock Coordinator for HA
6070

@@ -64,7 +74,7 @@ The key feature of this example is the use of **distributed locks** to control w
6474
<lock-coordinators>
6575
<lock-coordinator name="clients-lock">
6676
<class-name>org.apache.activemq.artemis.lockmanager.file.FileBasedLockManager</class-name>
67-
<lock-id>star-mirror-cluster-clients</lock-id>
77+
<lock-id>mesh-mirror-cluster-clients</lock-id>
6878
<check-period>1000</check-period>
6979
<properties>
7080
<property key="locks-folder" value="/path/to/shared/locks"/>
@@ -97,7 +107,7 @@ When the active broker (holding the lock) fails:
97107
1. The lock is automatically released
98108
2. One of the backup brokers acquires the lock and starts accepting connections
99109
3. The client automatically reconnects to the now-active broker
100-
4. All messages are available due to star mirroring
110+
4. All messages are available due to mesh mirroring
101111

102112
## Setup
103113

@@ -107,7 +117,7 @@ You have the following options to run this example:
107117

108118
### Non-interactive way
109119

110-
You can run this example in a non-interactive way, with HAWithStarMirrorExample starting, stopping the servers, and consume messages from your servers during failover.
120+
You can run this example in a non-interactive way, with HAWithMeshMirrorExample starting, stopping the servers, and consume messages from your servers during failover.
111121

112122
```shell
113123
mvn verify -Pautomated
@@ -206,7 +216,7 @@ To observe the high availability in action:
206216

207217
## Example Flow
208218

209-
1. All three brokers start with star mirroring configured
219+
1. All three brokers start with mesh mirroring configured
210220
2. One broker (typically server0) acquires the distributed lock and accepts client connections
211221
3. The client connects and sends 30 messages to a queue
212222
4. Server0 is killed (simulating a failure)
@@ -220,7 +230,7 @@ The lock coordinator supports different lock types (file-based, ZooKeeper). This
220230

221231
The `check-period` parameter (in milliseconds) controls how frequently the lock holder verifies it still owns the lock, affecting how quickly failover occurs when a broker crashes.
222232

223-
**Important:** This example demonstrates the star topology with lock coordinator on broker connections. Unlike the dual mirror example, the lock-coordinator attribute is specified on the broker connections themselves, ensuring that mirroring only occurs when a broker holds the lock. This prevents multiple brokers from simultaneously trying to mirror to each other when they don't have the client lock.
233+
**Important:** This example demonstrates the mesh topology with lock coordinator on broker connections. Unlike the dual mirror example, the lock-coordinator attribute is specified on the broker connections themselves, ensuring that mirroring only occurs when a broker holds the lock. This prevents multiple brokers from simultaneously trying to mirror to each other when they don't have the client lock.
224234

225235
## Change the configuration to ZooKeeper
226236

@@ -230,7 +240,7 @@ If you want to try ZooKeeper, you need to change the lock-coordinator configurat
230240
<lock-coordinators>
231241
<lock-coordinator name="clients-lock">
232242
<class-name>org.apache.activemq.artemis.lockmanager.zookeeper.CuratorDistributedLockManager</class-name>
233-
<lock-id>star-mirror-cluster-clients</lock-id>
243+
<lock-id>mesh-mirror-cluster-clients</lock-id>
234244
<check-period>1000</check-period>
235245

236246
<properties>

examples/features/broker-connection/ha-with-star-mirror/screen-clients.sh renamed to examples/features/broker-connection/ha-with-mesh-mirror/screen-clients.sh

File renamed without changes.

examples/features/broker-connection/ha-with-star-mirror/screen-servers.sh renamed to examples/features/broker-connection/ha-with-mesh-mirror/screen-servers.sh

File renamed without changes.

examples/features/broker-connection/ha-with-star-mirror/servers-layout.conf renamed to examples/features/broker-connection/ha-with-mesh-mirror/servers-layout.conf

File renamed without changes.

examples/features/broker-connection/ha-with-star-mirror/src/main/java/org/apache/artemis/jms/example/Consumer.java renamed to examples/features/broker-connection/ha-with-mesh-mirror/src/main/java/org/apache/artemis/jms/example/Consumer.java

File renamed without changes.

examples/features/broker-connection/ha-with-star-mirror/src/main/java/org/apache/artemis/jms/example/CreateServers.java renamed to examples/features/broker-connection/ha-with-mesh-mirror/src/main/java/org/apache/artemis/jms/example/CreateServers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
*/
2222
public class CreateServers {
2323
public static void main(final String[] args) throws Exception {
24-
HAWithStarMirrorExample.configureLocksFolder(args);
24+
HAWithMeshMirrorExample.configureLocksFolder(args);
2525
}
2626
}

examples/features/broker-connection/ha-with-star-mirror/src/main/java/org/apache/artemis/jms/example/HAWithStarMirrorExample.java renamed to examples/features/broker-connection/ha-with-mesh-mirror/src/main/java/org/apache/artemis/jms/example/HAWithMeshMirrorExample.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
import org.apache.activemq.artemis.utils.FileUtil;
3131

3232
/**
33-
* Example of star topology mirroring with three servers using lock coordinator on broker connections
33+
* Example of mesh topology mirroring with three servers using lock coordinator on broker connections
3434
*/
35-
public class HAWithStarMirrorExample {
35+
public class HAWithMeshMirrorExample {
3636

3737
private static Process server0;
3838

@@ -51,11 +51,11 @@ public static void main(final String[] args) throws Exception {
5151
try {
5252

5353
// Start the three servers
54-
server0 = ServerUtil.startServer(args[0], HAWithStarMirrorExample.class.getSimpleName() + "-peer0", 0, 0);
54+
server0 = ServerUtil.startServer(args[0], HAWithMeshMirrorExample.class.getSimpleName() + "-peer0", 0, 0);
5555
Thread.sleep(2_000);
56-
server1 = ServerUtil.startServer(args[1], HAWithStarMirrorExample.class.getSimpleName() + "-peer1", 1, 0);
56+
server1 = ServerUtil.startServer(args[1], HAWithMeshMirrorExample.class.getSimpleName() + "-peer1", 1, 0);
5757
Thread.sleep(2_000);
58-
server2 = ServerUtil.startServer(args[2], HAWithStarMirrorExample.class.getSimpleName() + "-peer2", 2, 0);
58+
server2 = ServerUtil.startServer(args[2], HAWithMeshMirrorExample.class.getSimpleName() + "-peer2", 2, 0);
5959

6060
// We connect to the broker holding the lock on the distributed lock
6161
ConnectionFactory factory = new org.apache.qpid.jms.JmsConnectionFactory(

examples/features/broker-connection/ha-with-star-mirror/src/main/java/org/apache/artemis/jms/example/Producer.java renamed to examples/features/broker-connection/ha-with-mesh-mirror/src/main/java/org/apache/artemis/jms/example/Producer.java

File renamed without changes.

0 commit comments

Comments
 (0)