0

I am new to ActiveMQ. I am trying to configure ActiveMQ high availability using shared JDBC master/slave with MySQL. When the master fails the slave automatically takes charge (i.e. becomes the master) and grabs the lock in MySQL. I wanted to know if there is any way we can fix a broker as master so that if the slave takes charge and then the master gets reconnected and accepts connections again it doesn't have to wait for slave to fail.

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
Areej Fatimah
  • 251
  • 2
  • 11

1 Answers1

1

ActiveMQ "Classic" doesn't support the notion of configuring a broker specifically as a master or a slave. You simply configure 2 brokers to use the same shared storage (whether that's disk or database) and whichever broker gets the lock first is the master broker and stays the master broker until it fails.

You'd need to use ActiveMQ Artemis and configure failback to support your use-case.

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
  • Will our application be able to figure out which broker took over i.e. which broker becomes the master, if yes then how? – Areej Fatimah Jun 22 '22 at 06:19
  • 1
    If your application is using the core JMS client that ships with ActiveMQ Artemis then it will failback to the original master automatically just like the brokers do assuming you're using `ha=true` and have a `reconnectAttempts` > 0 in your connection URL. – Justin Bertram Jun 22 '22 at 13:08
  • In case of ActiveMQ "Classic" with JMS client, how to keep track of master broker, apart from the logs that are maintained that which broker is listening for connections? – Areej Fatimah Jun 22 '22 at 13:26
  • 1
    If you're using the OpenWire JMS client that ships with ActiveMQ "Classic" then you should use the [`failover:` transport](https://activemq.apache.org/failover-transport-reference.html) with the URL of both the master and slave brokers. That way whenever there is a failover or failback then the client will automatically reconnect. – Justin Bertram Jun 22 '22 at 14:26
  • I don't understand your question, @AreejFatimah. A slave is _already_ passive. – Justin Bertram Aug 01 '22 at 15:03