public class MqttConfig
extends java.lang.Object
Constructor and Description |
---|
MqttConfig()
Create a new configuration.
|
MqttConfig(java.lang.String serverURL,
java.lang.String clientId)
Create a new configuration.
|
Modifier and Type | Method and Description |
---|---|
static MqttConfig |
fromProperties(java.util.Properties properties)
Create a new configuration from
Properties . |
long |
getActionTimeToWaitMillis()
Get the maximum time to wait for an action (e.g., publish message) to complete.
|
java.lang.String |
getClientId()
Get the connection Client Id.
|
int |
getConnectionTimeout()
Get the connection timeout.
|
int |
getIdleTimeout()
Get the idle connection timeout.
|
int |
getKeepAliveInterval()
Get the connection Keep alive interval.
|
java.lang.String |
getKeyStore()
Get the SSL trust store path.
|
char[] |
getKeyStorePassword()
Get the SSL key store path password.
|
char[] |
getPassword()
Get the the password to use for authentication with the server.
|
org.eclipse.paho.client.mqttv3.MqttClientPersistence |
getPersistence()
Get the QoS 1 and 2 in-flight message persistence handler.
|
java.lang.String[] |
getServerURLs()
Get the MQTT Server URLs
|
int |
getSubscriberIdleReconnectInterval()
Get the subscriber idle reconnect interval.
|
java.lang.String |
getTrustStore()
Get the SSL trust store path.
|
char[] |
getTrustStorePassword()
Get the SSL trust store path password.
|
java.lang.String |
getUserName()
Get the username to use for authentication with the server.
|
java.lang.String |
getWillDestination()
Get a Last Will and Testament message's destination topic.
|
byte[] |
getWillPayload()
Get a Last Will and Testament message's payload.
|
int |
getWillQOS()
Get a Last Will and Testament message's QOS.
|
boolean |
getWillRetained()
Get a Last Will and Testament message's "retained" setting.
|
boolean |
isCleanSession()
Get the clean session setting.
|
java.lang.Object |
options()
INTERNAL USE ONLY.
|
void |
setActionTimeToWaitMillis(long actionTimeToWaitMillis)
Maximum time to wait for an action (e.g., publish message) to complete.
|
void |
setCleanSession(boolean cleanSession)
Clean Session.
|
void |
setClientId(java.lang.String clientId)
Connection Client Id.
|
void |
setConnectionTimeout(int connectionTimeoutSec)
Connection timeout.
|
void |
setIdleTimeout(int idleTimeoutSec)
Idle connection timeout.
|
void |
setKeepAliveInterval(int keepAliveSec)
Connection Keep alive.
|
void |
setKeyStore(java.lang.String path)
Set the SSL key store path.
|
void |
setKeyStorePassword(char[] password)
Set the SSL key store password.
|
void |
setPassword(char[] password)
Set the password to use for authentication with the server.
|
void |
setPersistence(org.eclipse.paho.client.mqttv3.MqttClientPersistence persistence)
QoS 1 and 2 in-flight message persistence.
|
void |
setServerURLs(java.lang.String[] serverUrls)
MQTT Server URLs
|
void |
setSubscriberIdleReconnectInterval(int seconds)
Subscriber idle reconnect interval.
|
void |
setTrustStore(java.lang.String path)
Set the SSL trust store path.
|
void |
setTrustStorePassword(char[] password)
Set the SSL trust store password.
|
void |
setUserName(java.lang.String userName)
Set the username to use for authentication with the server.
|
void |
setWill(java.lang.String topic,
byte[] payload,
int qos,
boolean retained)
Last Will and Testament.
|
public MqttConfig()
public MqttConfig(java.lang.String serverURL, java.lang.String clientId)
serverURL
- the MQTT broker's URLclientId
- the MQTT client's id. Auto-generated if null.public static MqttConfig fromProperties(java.util.Properties properties)
Properties
.
There is a property corresponding to each MqttConfig.set<name>()
method. Unless otherwise stated, the property's value is a string
of the corresponding method's argument type.
Properties not specified yield a configuration value as
described by and their corresponding set<name>()
.
Properties other than those noted are ignored.
tcp://<host>:<port>
or
ssl://<host>:<port>
properties
- properties specifying the configuration.java.lang.IllegalArgumentException
- for illegal valuespublic java.lang.String getClientId()
public long getActionTimeToWaitMillis()
public org.eclipse.paho.client.mqttv3.MqttClientPersistence getPersistence()
public int getConnectionTimeout()
public int getIdleTimeout()
public int getSubscriberIdleReconnectInterval()
public int getKeepAliveInterval()
public java.lang.String[] getServerURLs()
public java.lang.String getWillDestination()
public byte[] getWillPayload()
public int getWillQOS()
public boolean getWillRetained()
public boolean isCleanSession()
public char[] getPassword()
public java.lang.String getUserName()
public void setClientId(java.lang.String clientId)
Optional. default null: a clientId is auto-generated.
clientId
- the client idpublic void setActionTimeToWaitMillis(long actionTimeToWaitMillis)
Optional. default: -1 no timeout. 0 also means no timeout.
actionTimeToWaitMillis
- the time to wait in millisecondspublic void setPersistence(org.eclipse.paho.client.mqttv3.MqttClientPersistence persistence)
optional. default: use memory persistence.
persistence
- the persistence implementationpublic void setCleanSession(boolean cleanSession)
Qptional. default: true.
cleanSession
- the clean session valuepublic void setConnectionTimeout(int connectionTimeoutSec)
connectionTimeoutSec
- the timeout in secondspublic void setIdleTimeout(int idleTimeoutSec)
Following an idle disconnect, the connector will automatically
reconnect when it receives a new tuple to publish.
If the connector is subscribing to topics, it will also reconnect
as per setSubscriberIdleReconnectInterval(int)
.
idleTimeoutSec
- the timeout in secondssetSubscriberIdleReconnectInterval(int)
public void setSubscriberIdleReconnectInterval(int seconds)
Following an idle disconnect, if the connector is subscribing to topics, it will reconnect after the specified interval. Optional. default: 60 seconds.
seconds
- the interval in secondspublic void setKeepAliveInterval(int keepAliveSec)
Optional. 0 disables keepalive processing. default: 60 seconds.
keepAliveSec
- the interval in secondspublic void setServerURLs(java.lang.String[] serverUrls)
Required. Must be an array of one or more MQTT server URLs. When connecting, the first URL that successfully connects is used.
serverUrls
- the URLspublic void setWill(java.lang.String topic, byte[] payload, int qos, boolean retained)
optional. default: no last-will-and-testament.
topic
- topic to publish topayload
- the last-will-and-testament message valueqos
- the quality of service to use to publish the messageretained
- true to retain the message across connectionspublic void setPassword(char[] password)
password
- the passwordpublic void setUserName(java.lang.String userName)
userName
- the user namepublic void setTrustStore(java.lang.String path)
Only used with "ssl:" serverURL. Path to trust store file in JKS format. If not set, the standard JRE and javax.net.ssl system properties control the SSL behavior. Generally not required if server has a CA-signed certificate.
path
- the path. null to unset.public java.lang.String getTrustStore()
public void setTrustStorePassword(char[] password)
Required if the trust store path is set.
password
- the passwordpublic char[] getTrustStorePassword()
public void setKeyStore(java.lang.String path)
Only used with "ssl:" serverURL when the server is configured for client auth. Path to trust store file in JKS format. If not set, the standard JRE and javax.net.ssl system properties control the SSL behavior.
path
- the path. null to unset.public java.lang.String getKeyStore()
public void setKeyStorePassword(char[] password)
Required if the key store path is set.
password
- the password. null to unset.public char[] getKeyStorePassword()
public java.lang.Object options()
Copyright © 2016 The Apache Software Foundation. All Rights Reserved - bbe71fa-20161201-1641