aries aries - 7 months ago 55
Java Question

Eclipse paho connecting to distributed broker

I am using Apache Artemis as my mqtt broker. I have an Artemis cluster which is configured in Master-Slave fashion. When the Master server fails, the backup server takes over and the client has to connect to the slave server. Master and slave are having different IP.

Is there an option to specify multiple connect url (address of master and slave) while creating a MqttClient object in eclipse paho?

Something like

MqttClient cl = new MqttClient("LIST OF IPs", "Publisher", new

instead of just

MqttClient cl = new MqttClient("tcp://localhost:1883", "Publisher", new

such that when the connection to first address fails, a connection to the next address is tried.

Could someone please guide in this? Much appreciated.


Client libraries in many languages have this option. The list can be checked here:

For those clients for which "high-availability" is marked, support list of urls to be specified using the "MqttConnectOptions".


        String[] URIs = {"address1","address2"};
        MqttConnectOptions mqttConnectOptions = new MqttConnectOptions();