[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[paho-dev] Java Client now handles a list of MQTT servers.
|
I have checked a change into the Develop
stream that allows an application to supply a list of servers for the client
to attempt to connect to. The list is provide via a new setServerURIs method
on the MqttConnectOptions object. The JavaDoc for the method is pasted
below. Existing applications that pass a serverURI on the client
constructor will carry on working unchanged.
setServerURIs
public void setServerURIs(java.lang.String[] array)
Set a list of one or more serverURIs the client may connect
to.
Each serverURI
specifies the address of a server that the client may connect to. Two types
of connection are supported tcp://
for a TCP connection and ssl://
for a TCP connection secured by SSL/TLS. For example:
- tcp://localhost:1883
- ssl://localhost:8883
If
the port is not specified, it will default to 1883 for tcp://"
URIs, and 8883 for ssl://
URIs.
If serverURIs is set then it overrides the serverURI parameter
passed in on the constructor of the MQTT client.
When an attempt to connect is initiated the client will
start with the first serverURI in the list and work through the list until
a connection is established with a server. If a connection cannot be made
to any of the servers then the connect attempt fails.
Specifying a list of servers that a client may connect
to has several uses:
1. High
Availability and reliable message delivery
Some MQTT servers support a high availability feature where
two or more "equal" MQTT servers share state. An MQTT client
can connect to any of the "equal" servers and be assured that
messages are reliably delivered and durable subscriptions are maintained
no matter which server the client connects to.
The cleansession flag must be set to false if durable subscriptions
and/or reliable message delivery is required.
2. Hunt
List
A set of servers may be specified that are not "equal"
(as in the high availability option). As no state is shared across the
servers reliable message delivery and durable subscriptions are not valid.
The cleansession flag must be set to true if the hunt list mode is used
Parameters:
array - of serverURIs
All the best
Dave
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number
741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
3AU