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 Stringstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final booleanstatic final intstatic final booleanFields 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.intintintintintbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleansetAckTimeout(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.setAutoAck(boolean autoAck) Set to false to let the application code to ack the message via.invalid reference
MqttPublishMessage#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)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.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 sizesetRecvByteBufAllocatorSize(int recvByteBufAllocatorSize) Set the size for the FixedRecvByteBufAllocator used on the channel.setSsl(boolean ssl) Set whether SSL/TLS is enabledsetTrustAll(boolean trustAll) Set whether all server certificates should be trustedsetTrustOptions(TrustOptions options) Set the trust options.setUsername(String username) Set the usernamesetWillFlag(boolean willFlag) Set if will information are provided on connectionsetWillMessageBytes(Buffer willMessage) Set the content of the will messagesetWillQoS(int willQoS) Set the QoS level for the will messagesetWillRetain(boolean willRetain) Set if the will message must be retainedsetWillTopic(String willTopic) Set the topic on which the will message will be publishedtoJson()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_TSL_PORT
public static final int DEFAULT_TSL_PORT- See Also:
-
DEFAULT_HOST
- See Also:
-
DEFAULT_WILL_QOS
public static final int DEFAULT_WILL_QOS- 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
public static final boolean DEFAULT_WILL_FLAG- See Also:
-
DEFAULT_WILL_RETAIN
public static final boolean DEFAULT_WILL_RETAIN- 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:
-
-
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
-
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
- Returns:
- provided username
-
getPassword
- Returns:
- provided password
-
getClientId
- Returns:
- client identifier
-
getWillTopic
- Returns:
- topic on which the will message will be published
-
getWillMessageBytes
- 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
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
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
-
setWillFlag
Set if will information are provided on connection- Parameters:
willFlag- if will information are provided on connection- Returns:
- current options instance
-
setWillQoS
Set the QoS level for the will message- Parameters:
willQoS- QoS level for the will message- Returns:
- current options instance
-
setWillRetain
Set if the will message must be retained- Parameters:
willRetain- if thw 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 via. If true, the ack (PUBACK/PUBCOMP) will be sent by vertx-mqtt beforeinvalid reference
MqttPublishMessage#ack()execution. (default is true)invalid reference
MqttClient#publishHandler()- Parameters:
autoAck-
-
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
-
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
-