Package io.vertx.mqtt
Class MqttClientOptions
- java.lang.Object
-
- io.vertx.core.net.NetworkOptions
-
- io.vertx.core.net.TCPSSLOptions
-
- io.vertx.core.net.ClientOptionsBase
-
- io.vertx.core.net.NetClientOptions
-
- io.vertx.mqtt.MqttClientOptions
-
public class MqttClientOptions extends NetClientOptions
Represents options used by the MQTT client.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_ACK_TIMEOUT
static boolean
DEFAULT_AUTO_ACK
static boolean
DEFAULT_CLEAN_SESSION
static String
DEFAULT_HOST
static int
DEFAULT_KEEP_ALIVE_INTERVAL
static int
DEFAULT_MAX_INFLIGHT_QUEUE
static int
DEFAULT_MAX_MESSAGE_SIZE
static int
DEFAULT_PORT
static int
DEFAULT_TSL_PORT
static boolean
DEFAULT_WILL_FLAG
static int
DEFAULT_WILL_QOS
static boolean
DEFAULT_WILL_RETAIN
-
Fields inherited from class io.vertx.core.net.NetClientOptions
DEFAULT_HOSTNAME_VERIFICATION_ALGORITHM, DEFAULT_RECONNECT_ATTEMPTS, DEFAULT_RECONNECT_INTERVAL, DEFAULT_REGISTER_WRITE_HANDLER
-
Fields inherited from class io.vertx.core.net.ClientOptionsBase
DEFAULT_CONNECT_TIMEOUT, DEFAULT_METRICS_NAME
-
Fields inherited from class io.vertx.core.net.TCPSSLOptions
DEFAULT_IDLE_TIMEOUT, DEFAULT_IDLE_TIMEOUT_TIME_UNIT, DEFAULT_READ_IDLE_TIMEOUT, DEFAULT_SO_LINGER, DEFAULT_SSL, DEFAULT_SSL_ENGINE, DEFAULT_TCP_CORK, DEFAULT_TCP_FAST_OPEN, DEFAULT_TCP_KEEP_ALIVE, DEFAULT_TCP_NO_DELAY, DEFAULT_TCP_QUICKACK, DEFAULT_TCP_USER_TIMEOUT, DEFAULT_WRITE_IDLE_TIMEOUT
-
Fields inherited from class io.vertx.core.net.NetworkOptions
DEFAULT_LOG_ACTIVITY_FORMAT, DEFAULT_LOG_ENABLED, DEFAULT_RECEIVE_BUFFER_SIZE, DEFAULT_REUSE_ADDRESS, DEFAULT_REUSE_PORT, DEFAULT_SEND_BUFFER_SIZE, DEFAULT_TRAFFIC_CLASS
-
-
Constructor Summary
Constructors Constructor Description MqttClientOptions()
Default constructorMqttClientOptions(JsonObject json)
Create an instance of MqttClientOptions from JSONMqttClientOptions(MqttClientOptions other)
Copy constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description MqttClientOptions
addCrlPath(String crlPath)
Add a CRL pathMqttClientOptions
addCrlValue(Buffer crlValue)
Add a CRL valueMqttClientOptions
addEnabledCipherSuite(String suite)
Add an enabled cipher suite, appended to the ordered suites.MqttClientOptions
addEnabledSecureTransportProtocol(String protocol)
Add an enabled SSL/TLS protocols, appended to the ordered protocols.int
getAckTimeout()
Gets the time in seconds after which the client stops waiting for a PUBACK, PUBREC or PUBCOMP packet from the server in response to a packet it has sent.String
getClientId()
int
getKeepAliveInterval()
int
getMaxInflightQueue()
int
getMaxMessageSize()
String
getPassword()
String
getUsername()
String
getWillMessage()
Deprecated.Buffer
getWillMessageBytes()
int
getWillQoS()
String
getWillTopic()
boolean
hasPassword()
boolean
hasUsername()
boolean
isAutoAck()
boolean
isAutoGeneratedClientId()
boolean
isAutoKeepAlive()
boolean
isCleanSession()
boolean
isWillFlag()
boolean
isWillRetain()
MqttClientOptions
setAckTimeout(int ackTimeoutSeconds)
Sets the time in seconds after which the client will stop waiting for a PUBACK, PUBREC or PUBCOMP packet from the server in response to a packet it has sent.void
setAutoAck(boolean autoAck)
Set to false to let the application code to ack the message viaMqttPublishMessage#ack()
.MqttClientOptions
setAutoGeneratedClientId(boolean isAutoGeneratedClientId)
Set if the MQTT client must generate clientId automatically (default is true)MqttClientOptions
setAutoKeepAlive(boolean isAutoKeepAlive)
Set if the MQTT client must handle PINGREQ automatically (default is true)MqttClientOptions
setCleanSession(boolean cleanSession)
Set to start with a clean session (or not)MqttClientOptions
setClientId(String clientId)
Set the client identifierMqttClientOptions
setHostnameVerificationAlgorithm(String hostnameVerificationAlgorithm)
Set the hostname verification algorithm interval To disable hostname verification, set hostnameVerificationAlgorithm to an empty StringMqttClientOptions
setKeepAliveInterval(int keepAliveInterval)
Set the keep alive interval in secondsMqttClientOptions
setKeyCertOptions(KeyCertOptions options)
Set the key/cert options.MqttClientOptions
setMaxInflightQueue(int maxInflightQueue)
Set max count of unacknowledged messagesMqttClientOptions
setMaxMessageSize(int maxMessageSize)
Set max MQTT message sizeMqttClientOptions
setPassword(String password)
Set the passwordMqttClientOptions
setReceiveBufferSize(int receiveBufferSize)
Set the TCP receive buffer sizeMqttClientOptions
setSsl(boolean ssl)
Set whether SSL/TLS is enabledMqttClientOptions
setTrustAll(boolean trustAll)
Set whether all server certificates should be trustedMqttClientOptions
setTrustOptions(TrustOptions options)
Set the trust options.MqttClientOptions
setUsername(String username)
Set the usernameMqttClientOptions
setWillFlag(boolean willFlag)
Set if will information are provided on connectionMqttClientOptions
setWillMessage(String willMessage)
Deprecated.MqttClientOptions
setWillMessageBytes(Buffer willMessage)
Set the content of the will messageMqttClientOptions
setWillQoS(int willQoS)
Set the QoS level for the will messageMqttClientOptions
setWillRetain(boolean willRetain)
Set if the will message must be retainedMqttClientOptions
setWillTopic(String willTopic)
Set the topic on which the will message will be publishedJsonObject
toJson()
Convert to JSONString
toString()
-
Methods inherited from class io.vertx.core.net.NetClientOptions
addNonProxyHost, getApplicationLayerProtocols, getHostnameVerificationAlgorithm, getReconnectAttempts, getReconnectInterval, isRegisterWriteHandler, removeEnabledCipherSuite, removeEnabledSecureTransportProtocol, setActivityLogDataFormat, setApplicationLayerProtocols, setConnectTimeout, setEnabledSecureTransportProtocols, setIdleTimeout, setIdleTimeoutUnit, setLocalAddress, setLogActivity, setMetricsName, setNonProxyHosts, setProxyOptions, setReadIdleTimeout, setReconnectAttempts, setReconnectInterval, setRegisterWriteHandler, setReuseAddress, setReusePort, setSendBufferSize, setSoLinger, setSslEngineOptions, setSslHandshakeTimeout, setSslHandshakeTimeoutUnit, setTcpCork, setTcpFastOpen, setTcpKeepAlive, setTcpNoDelay, setTcpQuickAck, setTrafficClass, setUseAlpn, setWriteIdleTimeout
-
Methods inherited from class io.vertx.core.net.ClientOptionsBase
getConnectTimeout, getLocalAddress, getMetricsName, getNonProxyHosts, getOrCreateSSLOptions, getProxyOptions, getSslOptions, isTrustAll, setTcpUserTimeout
-
Methods inherited from class io.vertx.core.net.TCPSSLOptions
getCrlPaths, getCrlValues, getEnabledCipherSuites, getEnabledSecureTransportProtocols, getIdleTimeout, getIdleTimeoutUnit, getKeyCertOptions, getReadIdleTimeout, getSoLinger, getSslEngineOptions, getSslHandshakeTimeout, getSslHandshakeTimeoutUnit, getTcpUserTimeout, getTrustOptions, getWriteIdleTimeout, isSsl, isTcpCork, isTcpFastOpen, isTcpKeepAlive, isTcpNoDelay, isTcpQuickAck, isUseAlpn
-
Methods inherited from class io.vertx.core.net.NetworkOptions
getActivityLogDataFormat, getLogActivity, getReceiveBufferSize, getSendBufferSize, getTrafficClass, isReuseAddress, isReusePort
-
-
-
-
Field Detail
-
DEFAULT_PORT
public static final int DEFAULT_PORT
- See Also:
- Constant Field Values
-
DEFAULT_TSL_PORT
public static final int DEFAULT_TSL_PORT
- See Also:
- Constant Field Values
-
DEFAULT_HOST
public static final String DEFAULT_HOST
- See Also:
- Constant Field Values
-
DEFAULT_WILL_QOS
public static final int DEFAULT_WILL_QOS
- See Also:
- Constant Field Values
-
DEFAULT_KEEP_ALIVE_INTERVAL
public static final int DEFAULT_KEEP_ALIVE_INTERVAL
- See Also:
- Constant Field Values
-
DEFAULT_MAX_INFLIGHT_QUEUE
public static final int DEFAULT_MAX_INFLIGHT_QUEUE
- See Also:
- Constant Field Values
-
DEFAULT_CLEAN_SESSION
public static final boolean DEFAULT_CLEAN_SESSION
- See Also:
- Constant Field Values
-
DEFAULT_WILL_FLAG
public static final boolean DEFAULT_WILL_FLAG
- See Also:
- Constant Field Values
-
DEFAULT_WILL_RETAIN
public static final boolean DEFAULT_WILL_RETAIN
- See Also:
- Constant Field Values
-
DEFAULT_MAX_MESSAGE_SIZE
public static final int DEFAULT_MAX_MESSAGE_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_ACK_TIMEOUT
public static final int DEFAULT_ACK_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_AUTO_ACK
public static final boolean DEFAULT_AUTO_ACK
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MqttClientOptions
public MqttClientOptions()
Default constructor
-
MqttClientOptions
public MqttClientOptions(JsonObject json)
Create an instance of MqttClientOptions from JSON- Parameters:
json
- the JSON
-
MqttClientOptions
public MqttClientOptions(MqttClientOptions other)
Copy constructor- Parameters:
other
- the options to copy
-
-
Method Detail
-
hasUsername
public boolean hasUsername()
- Returns:
- if username is provided
-
hasPassword
public boolean hasPassword()
- Returns:
- if password is provided
-
isCleanSession
public boolean isCleanSession()
- Returns:
- if client wants to start with a clean session
-
isWillFlag
public boolean isWillFlag()
- Returns:
- if will information are provided on connection
-
isWillRetain
public boolean isWillRetain()
- Returns:
- if the will messages must be retained
-
getWillQoS
public int getWillQoS()
- Returns:
- the QoS level for the will message
-
getKeepAliveInterval
public int getKeepAliveInterval()
- Returns:
- the keep alive interval (in seconds)
-
getUsername
public String getUsername()
- Returns:
- provided username
-
getPassword
public String getPassword()
- Returns:
- provided password
-
getClientId
public String getClientId()
- Returns:
- client identifier
-
getWillTopic
public String getWillTopic()
- Returns:
- topic on which the will message will be published
-
getWillMessage
@Deprecated public String getWillMessage()
Deprecated.- Returns:
- will message content
-
getWillMessageBytes
public Buffer getWillMessageBytes()
- Returns:
- will message bytes content
-
setClientId
public MqttClientOptions setClientId(String clientId)
Set the client identifier- Parameters:
clientId
- client identifier- Returns:
- current options instance
-
setUsername
public MqttClientOptions setUsername(String username)
Set the username- Parameters:
username
- username- Returns:
- current options instance
-
setPassword
public MqttClientOptions setPassword(String password)
Set the password- Parameters:
password
- password- Returns:
- current options instance
-
setWillTopic
public MqttClientOptions setWillTopic(String willTopic)
Set the topic on which the will message will be published- Parameters:
willTopic
- topic on which the will message will be published- Returns:
- current options instance
-
setWillMessage
@Deprecated public MqttClientOptions setWillMessage(String willMessage)
Deprecated.Set the content of the will message- Parameters:
willMessage
- content of the will message- Returns:
- current options instance
-
setWillMessageBytes
public MqttClientOptions setWillMessageBytes(Buffer willMessage)
Set the content of the will message- Parameters:
willMessage
- content of the will message- Returns:
- current options instance
-
setCleanSession
public MqttClientOptions setCleanSession(boolean cleanSession)
Set to start with a clean session (or not)- Parameters:
cleanSession
- if clean session should be activated- Returns:
- current options instance
-
setWillFlag
public MqttClientOptions setWillFlag(boolean willFlag)
Set if will information are provided on connection- Parameters:
willFlag
- if will information are provided on connection- Returns:
- current options instance
-
setWillQoS
public MqttClientOptions setWillQoS(int willQoS)
Set the QoS level for the will message- Parameters:
willQoS
- QoS level for the will message- Returns:
- current options instance
-
setWillRetain
public MqttClientOptions setWillRetain(boolean willRetain)
Set if the will message must be retained- Parameters:
willRetain
- if thw will message must be retained- Returns:
- current options instance
-
setKeepAliveInterval
public MqttClientOptions setKeepAliveInterval(int keepAliveInterval)
Set the keep alive interval in seconds- Parameters:
keepAliveInterval
- keep alive interval in seconds- Returns:
- current options instance
-
getAckTimeout
public int getAckTimeout()
Gets the time in seconds after which the client stops waiting for a PUBACK, PUBREC or PUBCOMP packet from the server in response to a packet it has sent.The default value of this property is 10s.
- Returns:
- timeout in seconds
-
setAckTimeout
public MqttClientOptions setAckTimeout(int ackTimeoutSeconds)
Sets the time in seconds after which the client will stop waiting for a PUBACK, PUBREC or PUBCOMP packet from the server in response to a packet it has sent.The default value of this property is -1 which indicates that the client should wait an unlimited time for the server's acknowledgement.
- Parameters:
ackTimeoutSeconds
- timeout in seconds- Returns:
- current options instance
- Throws:
IllegalArgumentException
- if the timeout is 0 or < -1.
-
getMaxInflightQueue
public int getMaxInflightQueue()
- Returns:
- max count of unacknowledged messages
-
setMaxInflightQueue
public MqttClientOptions setMaxInflightQueue(int maxInflightQueue)
Set max count of unacknowledged messages- Parameters:
maxInflightQueue
- max count of unacknowledged messages- Returns:
- current options instance
-
setAutoKeepAlive
public MqttClientOptions setAutoKeepAlive(boolean isAutoKeepAlive)
Set if the MQTT client must handle PINGREQ automatically (default is true)- Parameters:
isAutoKeepAlive
- ping request handled automatically- Returns:
- current options instance
-
setAutoGeneratedClientId
public MqttClientOptions setAutoGeneratedClientId(boolean isAutoGeneratedClientId)
Set if the MQTT client must generate clientId automatically (default is true)- Parameters:
isAutoGeneratedClientId
- clientId generated automatically- Returns:
- current options instance
-
isAutoAck
public boolean isAutoAck()
- Returns:
- if the ack (PUBACK/PUBCOMP) will be sent automatically by vertx-mqtt
-
setAutoAck
public void setAutoAck(boolean autoAck)
Set to false to let the application code to ack the message viaMqttPublishMessage#ack()
. If true, the ack (PUBACK/PUBCOMP) will be sent by vertx-mqtt beforeMqttClient#publishHandler()
execution. (default is true)- Parameters:
autoAck
-
-
isAutoKeepAlive
public boolean isAutoKeepAlive()
- Returns:
- if the PINGREQ is handled automatically
-
isAutoGeneratedClientId
public boolean isAutoGeneratedClientId()
- Returns:
- if clientId generated automatically
-
getMaxMessageSize
public int getMaxMessageSize()
- Returns:
- max MQTT message size
-
setReceiveBufferSize
public MqttClientOptions setReceiveBufferSize(int receiveBufferSize)
Description copied from class:NetworkOptions
Set the TCP receive buffer size- Overrides:
setReceiveBufferSize
in classNetClientOptions
- Parameters:
receiveBufferSize
- the buffers size, in bytes- Returns:
- a reference to this, so the API can be used fluently
-
setMaxMessageSize
public MqttClientOptions setMaxMessageSize(int maxMessageSize)
Set max MQTT message size- Parameters:
maxMessageSize
- max MQTT message size- Returns:
- MQTT client options instance
-
setSsl
public MqttClientOptions setSsl(boolean ssl)
Description copied from class:TCPSSLOptions
Set whether SSL/TLS is enabled- Overrides:
setSsl
in classNetClientOptions
- Parameters:
ssl
- true if enabled- Returns:
- a reference to this, so the API can be used fluently
-
setHostnameVerificationAlgorithm
public MqttClientOptions setHostnameVerificationAlgorithm(String hostnameVerificationAlgorithm)
Description copied from class:NetClientOptions
Set the hostname verification algorithm interval To disable hostname verification, set hostnameVerificationAlgorithm to an empty String- Overrides:
setHostnameVerificationAlgorithm
in classNetClientOptions
- Parameters:
hostnameVerificationAlgorithm
- should be HTTPS, LDAPS or an empty String- Returns:
- a reference to this, so the API can be used fluently
-
setTrustAll
public MqttClientOptions setTrustAll(boolean trustAll)
Description copied from class:ClientOptionsBase
Set whether all server certificates should be trusted- Overrides:
setTrustAll
in classNetClientOptions
- Parameters:
trustAll
- true if all should be trusted- Returns:
- a reference to this, so the API can be used fluently
-
setKeyCertOptions
public MqttClientOptions setKeyCertOptions(KeyCertOptions options)
Description copied from class:TCPSSLOptions
Set the key/cert options.- Overrides:
setKeyCertOptions
in classNetClientOptions
- Parameters:
options
- the key store options- Returns:
- a reference to this, so the API can be used fluently
-
setTrustOptions
public MqttClientOptions setTrustOptions(TrustOptions options)
Description copied from class:TCPSSLOptions
Set the trust options.- Overrides:
setTrustOptions
in classNetClientOptions
- Parameters:
options
- the trust options- Returns:
- a reference to this, so the API can be used fluently
-
addEnabledCipherSuite
public MqttClientOptions addEnabledCipherSuite(String suite)
Description copied from class:TCPSSLOptions
Add an enabled cipher suite, appended to the ordered suites.- Overrides:
addEnabledCipherSuite
in classNetClientOptions
- Parameters:
suite
- the suite- Returns:
- a reference to this, so the API can be used fluently
- See Also:
TCPSSLOptions.getEnabledCipherSuites()
-
addEnabledSecureTransportProtocol
public MqttClientOptions addEnabledSecureTransportProtocol(String protocol)
Description copied from class:TCPSSLOptions
Add an enabled SSL/TLS protocols, appended to the ordered protocols.- Overrides:
addEnabledSecureTransportProtocol
in classNetClientOptions
- Parameters:
protocol
- the SSL/TLS protocol to enable- Returns:
- a reference to this, so the API can be used fluently
-
addCrlPath
public MqttClientOptions addCrlPath(String crlPath) throws NullPointerException
Description copied from class:TCPSSLOptions
Add a CRL path- Overrides:
addCrlPath
in classNetClientOptions
- Parameters:
crlPath
- the path- Returns:
- a reference to this, so the API can be used fluently
- Throws:
NullPointerException
-
addCrlValue
public MqttClientOptions addCrlValue(Buffer crlValue) throws NullPointerException
Description copied from class:TCPSSLOptions
Add a CRL value- Overrides:
addCrlValue
in classNetClientOptions
- Parameters:
crlValue
- the value- Returns:
- a reference to this, so the API can be used fluently
- Throws:
NullPointerException
-
toJson
public JsonObject toJson()
Description copied from class:ClientOptionsBase
Convert to JSON- Overrides:
toJson
in classNetClientOptions
- Returns:
- the JSON
-
-