Failover
This page explains how to configure JMS Bridge for failover, enabling seamless transition between a live server and a backup server. This configuration ensures high availability and reliability in message processing, allowing the system to automatically switch to a backup server in case of a primary (live) server failure. The configuration can be applied in environments using Virtual Machines (VMs) or Docker containers.
-
Install JMS Bridge on two virtual machines: one configured as the live server and the other as the backup server.
-
Add the following properties on both VM’s
broker.xml
file:<ha-policy><shared-store><master><failover-on-shutdown>true</failover-on-shutdown></master></shared-store></ha-policy><!-- Connectors --><connectors><connector name="live-netty-connector">tcp://<<live-jms-bridge-host>>:61616</connector><connector name="backup-netty-connector">tcp://<<backup-jms-bridge-host>>:61616</connector></connectors><cluster-connections><cluster-connection name="my-cluster"><connector-ref>live-netty-connector</connector-ref><static-connectors><connector-ref>backup-netty-connector</connector-ref></static-connectors></cluster-connection></cluster-connections><ha-policy><shared-store><slave><allow-failback>true</allow-failback></slave></shared-store></ha-policy><!-- Connectors --><connectors><connector name="live-netty-connector">tcp://<<live-jms-bridge-host>>:61616</connector><connector name="backup-netty-connector">tcp://<<backup-jms-bridge-host>>:61616</connector></connectors><cluster-connections><cluster-connection name="my-cluster"><connector-ref>backup-netty-connector</connector-ref><static-connectors><connector-ref>live-netty-connector</connector-ref></static-connectors></cluster-connection></cluster-connections> -
Start the broker on the Live VM first.
- Wait 30–40 seconds after starting the broker, then verify successful startup by checking the
logs/jms-bridge.out
file for the message: Server is now live.
- Wait 30–40 seconds after starting the broker, then verify successful startup by checking the
-
Then start broker on the backup VM.
- Wait 30–40 seconds after starting the broker, then verify successful startup by checking the
logs/jms-bridge.out
file for the message: Backup announced.
- Wait 30–40 seconds after starting the broker, then verify successful startup by checking the
-
If the live server fails, the backup server automatically transitions to the live state. Confirm this by checking the log message: Backup server is now live.
-
When the live server restarts, the backup server returns to standby mode automatically.
-
Ensure both
live-jms-bridge
andbackup-jms-bridge
containers are running in Docker. -
Verify this by checking the container’s log:
- live-jms-bridge - Server is now live.
- backup-jms-bridge - Backup announced.
-
Configure the client with the following connecting URL to enable failover between the live and backup brokers/servers:
java.naming.provider.url=(tcp://<<Live-server-host>>:61616,tcp://<<Backup-server-host>>:61617) -
If the live server fails, the backup server automatically transitions to the live state. Confirm this by checking the log message : Backup server is now live.
-
When the live server restarts, the backup server returns to standby mode automatically.