public class MqttOptions extends Object implements Serializable
MQTT Configuration Options
Modifier and Type | Class and Description |
---|---|
static class |
MqttOptions.Builder |
Constructor and Description |
---|
MqttOptions() |
Modifier and Type | Method and Description |
---|---|
long |
getConnectAttemptsMax() |
String |
getPassword() |
int |
getQos() |
long |
getReconnectAttemptsMax() |
double |
getReconnectBackOffMultiplier() |
long |
getReconnectDelay() |
long |
getReconnectDelayMax() |
List<String> |
getTopics() |
String |
getUrl() |
String |
getUserName() |
String |
getWillPayload() |
int |
getWillQos() |
boolean |
getWillRetain() |
String |
getWillTopic() |
boolean |
isCleanConnection() |
void |
setCleanConnection(boolean cleanConnection)
Set to false if you want the MQTT server to persist topic subscriptions and ack positions across client sessions.
|
void |
setConnectAttemptsMax(long connectAttemptsMax)
The maximum number of reconnect attempts before an error is reported back to the client on the first attempt by the client to connect to a server.
|
void |
setPassword(String password)
The password for authenticated sessions.
|
void |
setQos(int qos)
Sets the quality of service to use for MQTT messages.
|
void |
setReconnectAttemptsMax(long reconnectAttemptsMax)
The maximum number of reconnect attempts before an error is reported back to the client after a server connection had previously been established.
|
void |
setReconnectBackOffMultiplier(double reconnectBackOffMultiplier)
The Exponential backoff be used between reconnect attempts.
|
void |
setReconnectDelay(long reconnectDelay)
How long to wait in ms before the first reconnect attempt.
|
void |
setReconnectDelayMax(long reconnectDelayMax)
The maximum amount of time in ms to wait between reconnect attempts.
|
void |
setTopics(List<String> topics)
A list of MQTT topics to subscribe to.
|
void |
setUrl(String url)
Sets the url for connecting to the MQTT broker.
|
void |
setUserName(String userName)
The username for authenticated sessions.
|
void |
setWillPayload(String willPayload)
The Will message to send.
|
void |
setWillQos(int qos)
Sets the quality of service to use for the MQTT Will message.
|
void |
setWillRetain(boolean retain)
Set to true if you want the Will message to be published with the retain option.
|
void |
setWillTopic(String willTopic)
If set the server will publish the client’s Will message to the specified topics if the client has an unexpected disconnection.
|
public String getUrl()
public void setUrl(String url)
Sets the url for connecting to the MQTT broker.
Default: `tcp://localhost:1883’
url
- public void setTopics(List<String> topics)
A list of MQTT topics to subscribe to.
topics
- public boolean isCleanConnection()
public void setCleanConnection(boolean cleanConnection)
Set to false if you want the MQTT server to persist topic subscriptions and ack positions across client sessions. Defaults to false.
cleanConnection
- public String getWillTopic()
public void setWillTopic(String willTopic)
If set the server will publish the client’s Will message to the specified topics if the client has an unexpected disconnection.
willTopic
- public String getWillPayload()
public void setWillPayload(String willPayload)
The Will message to send. Defaults to a zero length message.
willPayload
- public long getReconnectDelay()
public void setReconnectDelay(long reconnectDelay)
How long to wait in ms before the first reconnect attempt. Defaults to 10.
reconnectDelay
- public long getReconnectDelayMax()
public void setReconnectDelayMax(long reconnectDelayMax)
The maximum amount of time in ms to wait between reconnect attempts. Defaults to 30,000.
reconnectDelayMax
- public double getReconnectBackOffMultiplier()
public void setReconnectBackOffMultiplier(double reconnectBackOffMultiplier)
The Exponential backoff be used between reconnect attempts. Set to 1 to disable exponential backoff. Defaults to 2.
reconnectBackOffMultiplier
- public long getReconnectAttemptsMax()
public void setReconnectAttemptsMax(long reconnectAttemptsMax)
The maximum number of reconnect attempts before an error is reported back to the client after a server connection had previously been established. Set to -1 to use unlimited attempts. Defaults to -1.
reconnectAttemptsMax
- public long getConnectAttemptsMax()
public void setConnectAttemptsMax(long connectAttemptsMax)
The maximum number of reconnect attempts before an error is reported back to the client on the first attempt by the client to connect to a server. Set to -1 to use unlimited attempts. Defaults to -1.
connectAttemptsMax
- public String getUserName()
public void setUserName(String userName)
The username for authenticated sessions.
userName
- public String getPassword()
public void setPassword(String password)
The password for authenticated sessions.
password
- public int getQos()
public void setQos(int qos)
Sets the quality of service to use for MQTT messages. Defaults to 1 (at least once).
qos
- public int getWillQos()
public void setWillQos(int qos)
Sets the quality of service to use for the MQTT Will message. Defaults to 1 (at least once).
qos
- public boolean getWillRetain()
public void setWillRetain(boolean retain)
Set to true if you want the Will message to be published with the retain option.
retain
- Copyright © 2019 The Apache Software Foundation. All Rights Reserved.