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
Represents options used by the MQTT client.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final booleanstatic final booleanstatic final booleanstatic final Stringstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final Integerstatic final intDeprecated.static final intstatic final booleanDeprecated.will message is now configured viaMqttClientWillOptions; this constant has no replacementstatic final intDeprecated.static final booleanDeprecated.Fields inherited from class NetClientOptions
DEFAULT_HOSTNAME_VERIFICATION_ALGORITHM, DEFAULT_RECONNECT_ATTEMPTS, DEFAULT_RECONNECT_INTERVAL, DEFAULT_REGISTER_WRITE_HANDLERFields inherited from class ClientOptionsBase
DEFAULT_CONNECT_TIMEOUT, DEFAULT_METRICS_NAMEFields inherited from class 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_KEEAPLIVE_COUNT, DEFAULT_TCP_KEEAPLIVE_IDLE_SECONDS, DEFAULT_TCP_KEEAPLIVE_INTERVAL_SECONDS, DEFAULT_TCP_KEEP_ALIVE, DEFAULT_TCP_NO_DELAY, DEFAULT_TCP_QUICKACK, DEFAULT_TCP_USER_TIMEOUT, DEFAULT_WRITE_IDLE_TIMEOUT -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorMqttClientOptions(JsonObject json) Create an instance of MqttClientOptions from JSONCopy constructor -
Method Summary
Modifier and TypeMethodDescriptionaddCrlPath(String crlPath) Add a CRL pathaddCrlValue(Buffer crlValue) Add a CRL valueaddEnabledCipherSuite(String suite) Add an enabled cipher suite, appended to the ordered suites.addEnabledSecureTransportProtocol(String protocol) Add an enabled SSL/TLS protocols, appended to the ordered protocols.intGets 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.intintintintintDeprecated.intDeprecated.Deprecated.booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanDeprecated.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.voidsetAuthenticationData(Buffer authenticationData) voidsetAuthenticationMethod(String authenticationMethod) setAutoAck(boolean autoAck) Set to false to let the application code to ack the message viaMqttPublishMessage.ack().setAutoGeneratedClientId(boolean isAutoGeneratedClientId) Set if the MQTT client must generate clientId automatically (default is true)setAutoKeepAlive(boolean isAutoKeepAlive) Set if the MQTT client must handle PINGREQ automatically (default is true)setAutoServerRedirect(boolean autoServerRedirect) Whentrue(default) and the broker replies with a CONNACK or DISCONNECT that includes aSERVER_REFERENCEproperty (MQTT 5.0 §3.2.2.3.18 / §3.14.2.3.4), the client will transparently reconnect to a server picked at random from the comma-separated list in that property instead of failing.setCleanSession(boolean cleanSession) Set to start with a clean session (or not)setClientId(String clientId) Set the client identifiersetHostnameVerificationAlgorithm(String hostnameVerificationAlgorithm) Set the hostname verification algorithm interval To disable hostname verification, set hostnameVerificationAlgorithm to an empty StringsetKeepAliveInterval(int keepAliveInterval) Set the keep alive interval in secondssetKeyCertOptions(KeyCertOptions options) Set the key/cert options.voidsetMaximumPacketSize(Long maximumPacketSize) setMaxInflightQueue(int maxInflightQueue) Set max count of unacknowledged messagessetMaxMessageSize(int maxMessageSize) Set max MQTT message sizesetPassword(String password) Set the passwordsetReceiveBufferSize(int receiveBufferSize) Set the TCP receive buffer sizevoidsetReceiveMaximum(Integer receiveMaximum) setRecvByteBufAllocatorSize(int recvByteBufAllocatorSize) Set the size for the FixedRecvByteBufAllocator used on the channel.voidsetRequestProblemInformation(Boolean requestProblemInformation) voidsetRequestResponseInformation(Boolean requestResponseInformation) voidsetSessionExpireInterval(Long sessionExpireInterval) setSsl(boolean ssl) Set whether SSL/TLS is enabledvoidsetTopicAliasMaximum(Integer topicAliasMaximum) setTrustAll(boolean trustAll) Set whether all server certificates should be trustedsetTrustOptions(TrustOptions options) Set the trust options.setUsername(String username) Set the usernamevoidsetVersion(int version) setWillMessageBytes(Buffer willMessage) Deprecated.setWillOptions(MqttClientWillOptions willOptions) Set the will message options.setWillQoS(int willQoS) Deprecated.setWillRetain(boolean willRetain) Deprecated.setWillTopic(String willTopic) Deprecated.toJson()Convert to JSONtoString()Methods inherited from class 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, setTcpUserTimeout, setTrafficClass, setUseAlpn, setWriteIdleTimeoutMethods inherited from class ClientOptionsBase
createSSLOptions, getConnectTimeout, getLocalAddress, getMetricsName, getNonProxyHosts, getOrCreateSSLOptions, getProxyOptions, getSslOptions, isTrustAllMethods inherited from class TCPSSLOptions
getCrlPaths, getCrlValues, getEnabledCipherSuites, getEnabledSecureTransportProtocols, getIdleTimeout, getIdleTimeoutUnit, getKeyCertOptions, getReadIdleTimeout, getReceiveBufferSize, getSendBufferSize, getSoLinger, getSslEngineOptions, getSslHandshakeTimeout, getSslHandshakeTimeoutUnit, getTcpKeepAliveCount, getTcpKeepAliveIdleSeconds, getTcpKeepAliveIntervalSeconds, getTcpUserTimeout, getTrafficClass, getTransportOptions, getTrustOptions, getWriteIdleTimeout, isReuseAddress, isReusePort, isSsl, isTcpCork, isTcpFastOpen, isTcpKeepAlive, isTcpNoDelay, isTcpQuickAck, isUseAlpn, setTcpKeepAliveCount, setTcpKeepAliveIdleSeconds, setTcpKeepAliveIntervalSecondsMethods inherited from class NetworkOptions
getActivityLogDataFormat, getLogActivity
-
Field Details
-
DEFAULT_PORT
public static final int DEFAULT_PORT- See Also:
-
DEFAULT_TLS_PORT
public static final int DEFAULT_TLS_PORT- See Also:
-
DEFAULT_TSL_PORT
Deprecated.UseDEFAULT_TLS_PORT(this constant has a typo in the name)- See Also:
-
DEFAULT_HOST
- See Also:
-
DEFAULT_WILL_QOS
Deprecated.- See Also:
-
DEFAULT_KEEP_ALIVE_INTERVAL
public static final int DEFAULT_KEEP_ALIVE_INTERVAL- See Also:
-
DEFAULT_MAX_INFLIGHT_QUEUE
public static final int DEFAULT_MAX_INFLIGHT_QUEUE- See Also:
-
DEFAULT_CLEAN_SESSION
public static final boolean DEFAULT_CLEAN_SESSION- See Also:
-
DEFAULT_WILL_FLAG
Deprecated.will message is now configured viaMqttClientWillOptions; this constant has no replacement- See Also:
-
DEFAULT_WILL_RETAIN
Deprecated.- See Also:
-
DEFAULT_MAX_MESSAGE_SIZE
public static final int DEFAULT_MAX_MESSAGE_SIZE- See Also:
-
DEFAULT_ACK_TIMEOUT
public static final int DEFAULT_ACK_TIMEOUT- See Also:
-
DEFAULT_AUTO_ACK
public static final boolean DEFAULT_AUTO_ACK- See Also:
-
DEFAULT_RECV_BYTE_BUF_ALLOCATOR_SIZE
public static final int DEFAULT_RECV_BYTE_BUF_ALLOCATOR_SIZE- See Also:
-
DEFAULT_VERSION
public static final int DEFAULT_VERSION- See Also:
-
DEFAULT_TOPIC_ALIAS_MAXIMUM
-
DEFAULT_AUTO_SERVER_REDIRECT
public static final boolean DEFAULT_AUTO_SERVER_REDIRECT- See Also:
-
-
Constructor Details
-
MqttClientOptions
public MqttClientOptions()Default constructor -
MqttClientOptions
Create an instance of MqttClientOptions from JSON- Parameters:
json- the JSON
-
MqttClientOptions
Copy constructor- Parameters:
other- the options to copy
-
-
Method Details
-
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
-
getWillOptions
- Returns:
- the will message options object (includes MQTT 5.0 properties)
-
setWillOptions
Set the will message options.- Parameters:
willOptions- will options- Returns:
- current options instance
-
isWillRetain
Deprecated.- Returns:
- if the will messages must be retained
-
getWillQoS
Deprecated.- Returns:
- the QoS level for the will message
-
getKeepAliveInterval
public int getKeepAliveInterval()- Returns:
- the keep alive interval (in seconds)
-
getUsername
- Returns:
- provided username
-
getPassword
- Returns:
- provided password
-
getClientId
- Returns:
- client identifier
-
getWillTopic
Deprecated.- Returns:
- topic on which the will message will be published
-
getWillMessageBytes
Deprecated.- Returns:
- will message bytes content
-
setClientId
Set the client identifier- Parameters:
clientId- client identifier- Returns:
- current options instance
-
setUsername
Set the username- Parameters:
username- username- Returns:
- current options instance
-
setPassword
Set the password- Parameters:
password- password- Returns:
- current options instance
-
setWillTopic
Deprecated.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
-
setWillMessageBytes
Deprecated.Set the content of the will message.- Parameters:
willMessage- content of the will message- Returns:
- current options instance
-
setCleanSession
Set to start with a clean session (or not)- Parameters:
cleanSession- if clean session should be activated- Returns:
- current options instance
-
setWillQoS
Deprecated.Set the QoS level for the will message.- Parameters:
willQoS- QoS level for the will message- Returns:
- current options instance
-
setWillRetain
Deprecated.Set if the will message must be retained.- Parameters:
willRetain- if the will message must be retained- Returns:
- current options instance
-
setKeepAliveInterval
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
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
Set max count of unacknowledged messages- Parameters:
maxInflightQueue- max count of unacknowledged messages- Returns:
- current options instance
-
setAutoKeepAlive
Set if the MQTT client must handle PINGREQ automatically (default is true)- Parameters:
isAutoKeepAlive- ping request handled automatically- Returns:
- current options instance
-
setAutoGeneratedClientId
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
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 beforeexecution. (default is true)invalid reference
MqttClient#publishHandler()- Parameters:
autoAck- if the ack (PUBACK/PUBCOMP) will be sent automatically by vertx-mqtt- Returns:
- current options instance
-
getRecvByteBufAllocatorSize
public int getRecvByteBufAllocatorSize()- Returns:
- the size for the FixedRecvByteBufAllocator, or -1 if not set
-
setRecvByteBufAllocatorSize
Set the size for the FixedRecvByteBufAllocator used on the channel. Use -1 (default) to leave the allocator unchanged.- Parameters:
recvByteBufAllocatorSize- the fixed buffer size in bytes, or -1 to disable- Returns:
- current options instance
-
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
Description copied from class:NetworkOptionsSet the TCP receive buffer size- Overrides:
setReceiveBufferSizein classNetClientOptions- Parameters:
receiveBufferSize- the buffers size, in bytes- Returns:
- a reference to this, so the API can be used fluently
-
setMaxMessageSize
Set max MQTT message size- Parameters:
maxMessageSize- max MQTT message size- Returns:
- MQTT client options instance
-
getVersion
public int getVersion() -
setVersion
public void setVersion(int version) -
getSessionExpireInterval
-
setSessionExpireInterval
-
getReceiveMaximum
-
setReceiveMaximum
-
getMaximumPacketSize
-
setMaximumPacketSize
-
getTopicAliasMaximum
-
setTopicAliasMaximum
-
getRequestResponseInformation
-
setRequestResponseInformation
-
getRequestProblemInformation
-
setRequestProblemInformation
-
getAuthenticationMethod
-
setAuthenticationMethod
-
getAuthenticationData
-
setAuthenticationData
-
isAutoServerRedirect
public boolean isAutoServerRedirect()- Returns:
- whether the client will automatically reconnect to the server indicated in the SERVER_REFERENCE property of a CONNACK or DISCONNECT packet (MQTT 5.0)
-
setAutoServerRedirect
Whentrue(default) and the broker replies with a CONNACK or DISCONNECT that includes aSERVER_REFERENCEproperty (MQTT 5.0 §3.2.2.3.18 / §3.14.2.3.4), the client will transparently reconnect to a server picked at random from the comma-separated list in that property instead of failing.- Parameters:
autoServerRedirect-trueto enable automatic server redirection- Returns:
- current options instance
-
setSsl
Description copied from class:TCPSSLOptionsSet whether SSL/TLS is enabled- Overrides:
setSslin classNetClientOptions- Parameters:
ssl- true if enabled- Returns:
- a reference to this, so the API can be used fluently
-
setHostnameVerificationAlgorithm
Description copied from class:NetClientOptionsSet the hostname verification algorithm interval To disable hostname verification, set hostnameVerificationAlgorithm to an empty String- Overrides:
setHostnameVerificationAlgorithmin classNetClientOptions- Parameters:
hostnameVerificationAlgorithm- should be HTTPS, LDAPS or an empty String- Returns:
- a reference to this, so the API can be used fluently
-
setTrustAll
Description copied from class:ClientOptionsBaseSet whether all server certificates should be trusted- Overrides:
setTrustAllin classNetClientOptions- Parameters:
trustAll- true if all should be trusted- Returns:
- a reference to this, so the API can be used fluently
-
setKeyCertOptions
Description copied from class:TCPSSLOptionsSet the key/cert options.- Overrides:
setKeyCertOptionsin classNetClientOptions- Parameters:
options- the key store options- Returns:
- a reference to this, so the API can be used fluently
-
setTrustOptions
Description copied from class:TCPSSLOptionsSet the trust options.- Overrides:
setTrustOptionsin classNetClientOptions- Parameters:
options- the trust options- Returns:
- a reference to this, so the API can be used fluently
-
addEnabledCipherSuite
Description copied from class:TCPSSLOptionsAdd an enabled cipher suite, appended to the ordered suites.- Overrides:
addEnabledCipherSuitein classNetClientOptions- Parameters:
suite- the suite- Returns:
- a reference to this, so the API can be used fluently
- See Also:
-
addEnabledSecureTransportProtocol
Description copied from class:TCPSSLOptionsAdd an enabled SSL/TLS protocols, appended to the ordered protocols.- Overrides:
addEnabledSecureTransportProtocolin classNetClientOptions- Parameters:
protocol- the SSL/TLS protocol to enable- Returns:
- a reference to this, so the API can be used fluently
-
addCrlPath
Description copied from class:TCPSSLOptionsAdd a CRL path- Overrides:
addCrlPathin classNetClientOptions- Parameters:
crlPath- the path- Returns:
- a reference to this, so the API can be used fluently
- Throws:
NullPointerException
-
addCrlValue
Description copied from class:TCPSSLOptionsAdd a CRL value- Overrides:
addCrlValuein classNetClientOptions- Parameters:
crlValue- the value- Returns:
- a reference to this, so the API can be used fluently
- Throws:
NullPointerException
-
toJson
Description copied from class:ClientOptionsBaseConvert to JSON- Overrides:
toJsonin classNetClientOptions- Returns:
- the JSON
-
toString
-
DEFAULT_TLS_PORT(this constant has a typo in the name)