Red Hat AMQ 6
As of February 2025, Red Hat is no longer supporting Red Hat AMQ 6. If you are using AMQ 6, please upgrade: Migrating to AMQ 7.1.3. Integrating with an ActiveMQ Failover Cluster
Overview Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
This section describes how to configure the ActiveMQ resource adapter to connect to an ActiveMQ failover cluster (for example, a high-availability master/slave cluster). For details about how to set up and configure such a cluster, see "Fault Tolerant Messaging".
Failover URL Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
To connect to a cluster of JBoss A-MQ brokers (for example, a master/slave pair of brokers), you need to configure the
ServerUrl configuration property with a failover URL, which lists the available endpoints in the cluster. The general form of the failover URL you should use is as follows:
failover:(uri1,...,uriN)?maxReconnectAttempts=0&reconnectSupported=false&updateURIsSupported=false&priorityBackup=false
failover:(uri1,...,uriN)?maxReconnectAttempts=0&reconnectSupported=false&updateURIsSupported=false&priorityBackup=false
Note
It is important to set the options as shown, in order to ensure a clean cutover when the master fails in a master/slave high-availability cluster. You do not want a failover client to attempt reconnection to the same endpoint. The client should always try the next URI in the failover list.
Sample scenario Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Consider the scenario where a broker running on host
amqhostA and a broker running on host amqhostB are configured to run as a high-availability master/slave cluster. In this scenario, the brokers expose the following TCP endpoints:
tcp://amqhostA:61616 tcp://amqhostB:61616
tcp://amqhostA:61616
tcp://amqhostB:61616
To connect to this cluster, the resource adapter should be configured with the following failover URL:
failover:(tcp://amqhostA:61616,tcp://amqhostB:61616)?jms.rmIdFromConnectionId=true&maxReconnectAttempts=0&reconnectSupported=false&updateURIsSupported=false&priorityBackup=false
failover:(tcp://amqhostA:61616,tcp://amqhostB:61616)?jms.rmIdFromConnectionId=true&maxReconnectAttempts=0&reconnectSupported=false&updateURIsSupported=false&priorityBackup=false
When setting the URL in an XML file, you must remember to escape the
& symbol as & giving the URL:
failover:(tcp://amqhostA:61616,tcp://amqhostB:61616)?jms.rmIdFromConnectionId=true&maxReconnectAttempts=0&reconnectSupported=false&updateURIsSupported=false&priorityBackup=false
failover:(tcp://amqhostA:61616,tcp://amqhostB:61616)?jms.rmIdFromConnectionId=true&maxReconnectAttempts=0&reconnectSupported=false&updateURIsSupported=false&priorityBackup=false
Configuring the ActiveMQ resource adapter for failover Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
To configure the ActiveMQ resource adapter to connect to an ActiveMQ failover cluster, you must modify the following configuration settings:
- Set the
ServerUrlconfiguration property to a correctly configured failover URL, - Set the
UseInboundSessionconfiguration property totruefor inbound connections (set as the direct child of theresource-adapterelement), and - Set the
UseInboundSessionconfiguration property tofalsefor the connection factories (set as the child of aconnection-definitionelement).
Open the
EAPInstallDir/standalone/configuration/standalone.xml file using a text editor, search for the urn:jboss:domain:resource-adapters:1.1 subsystem, and modify the ServerUrl property and the UseInboundSession property as shown in Example 1.3, “ActiveMQ Resource Adapter Configuration for Failover”. You will need to customize the value of the failover URL, as appropriate, to match the configuration of your broker cluster.
Example 1.3. ActiveMQ Resource Adapter Configuration for Failover