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 and Description
    --- | ---
    `static int` | `DEFAULT_ACK_TIMEOUT`
    `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`

    - ### Fields inherited from class io.vertx.core.net.ClientOptionsBase

      `DEFAULT_CONNECT_TIMEOUT, DEFAULT_METRICS_NAME, DEFAULT_TRUST_ALL`

    - ### Fields inherited from class io.vertx.core.net.TCPSSLOptions

      `DEFAULT_ENABLED_SECURE_TRANSPORT_PROTOCOLS, DEFAULT_IDLE_TIMEOUT, DEFAULT_IDLE_TIMEOUT_TIME_UNIT, DEFAULT_SO_LINGER, DEFAULT_SSL, DEFAULT_SSL_ENGINE, DEFAULT_SSL_HANDSHAKE_TIMEOUT, DEFAULT_SSL_HANDSHAKE_TIMEOUT_TIME_UNIT, DEFAULT_TCP_CORK, DEFAULT_TCP_FAST_OPEN, DEFAULT_TCP_KEEP_ALIVE, DEFAULT_TCP_NO_DELAY, DEFAULT_TCP_QUICKACK, DEFAULT_USE_ALPN`

    - ### Fields inherited from class io.vertx.core.net.NetworkOptions

      `DEFAULT_LOG_ENABLED, DEFAULT_RECEIVE_BUFFER_SIZE, DEFAULT_REUSE_ADDRESS, DEFAULT_REUSE_PORT, DEFAULT_SEND_BUFFER_SIZE, DEFAULT_TRAFFIC_CLASS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MqttClientOptions()` Default constructor
    `MqttClientOptions(JsonObject json)` Create an instance of MqttClientOptions from JSON
    `MqttClientOptions(MqttClientOptions other)` Copy constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `MqttClientOptions` | `addCrlPath(String crlPath)` Add a CRL path
    `MqttClientOptions` | `addCrlValue(Buffer crlValue)` Add a CRL value
    `MqttClientOptions` | `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()`
    `int` | `getWillQoS()`
    `String` | `getWillTopic()`
    `boolean` | `hasPassword()`
    `boolean` | `hasUsername()`
    `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.
    `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 identifier
    `MqttClientOptions` | `setIdleTimeout(int idleTimeout)` Deprecated.
    `MqttClientOptions` | `setKeepAliveInterval(int keepAliveInterval)` Set the keep alive interval in seconds
    `MqttClientOptions` | `setKeyCertOptions(KeyCertOptions options)` Set the key/cert options.
    `MqttClientOptions` | `setKeyStoreOptions(JksOptions options)` Set the key/cert options in jks format, aka Java keystore.
    `MqttClientOptions` | `setMaxInflightQueue(int maxInflightQueue)` Set max count of unacknowledged messages
    `MqttClientOptions` | `setMaxMessageSize(int maxMessageSize)` Set max MQTT message size
    `MqttClientOptions` | `setPassword(String password)` Set the password
    `MqttClientOptions` | `setPemKeyCertOptions(PemKeyCertOptions options)` Set the key/cert store options in pem format.
    `MqttClientOptions` | `setPemTrustOptions(PemTrustOptions options)` Set the trust options in pem format
    `MqttClientOptions` | `setPfxKeyCertOptions(PfxOptions options)` Set the key/cert options in pfx format.
    `MqttClientOptions` | `setPfxTrustOptions(PfxOptions options)` Set the trust options in pfx format
    `MqttClientOptions` | `setReceiveBufferSize(int receiveBufferSize)` Set the TCP receive buffer size
    `MqttClientOptions` | `setSsl(boolean ssl)` Set whether SSL/TLS is enabled
    `MqttClientOptions` | `setTrustAll(boolean trustAll)` Set whether all server certificates should be trusted
    `MqttClientOptions` | `setTrustOptions(TrustOptions options)` Set the trust options.
    `MqttClientOptions` | `setTrustStoreOptions(JksOptions options)` Set the trust options in jks format, aka Java truststore
    `MqttClientOptions` | `setUsername(String username)` Set the username
    `MqttClientOptions` | `setWillFlag(boolean willFlag)` Set if will information are provided on connection
    `MqttClientOptions` | `setWillMessage(String willMessage)` Set the content of the will message
    `MqttClientOptions` | `setWillQoS(int willQoS)` Set the QoS level for the will message
    `MqttClientOptions` | `setWillRetain(boolean willRetain)` Set if the will message must be retained
    `MqttClientOptions` | `setWillTopic(String willTopic)` Set the topic on which the will message will be published
    `String` | `toString()`

    - ### Methods inherited from class io.vertx.core.net.NetClientOptions

      `addNonProxyHost, getApplicationLayerProtocols, getHostnameVerificationAlgorithm, getReconnectAttempts, getReconnectInterval, removeEnabledSecureTransportProtocol, setApplicationLayerProtocols, setConnectTimeout, setEnabledSecureTransportProtocols, setHostnameVerificationAlgorithm, setIdleTimeoutUnit, setJdkSslEngineOptions, setLocalAddress, setLogActivity, setMetricsName, setNonProxyHosts, setOpenSslEngineOptions, setProxyOptions, setReconnectAttempts, setReconnectInterval, setReuseAddress, setReusePort, setSendBufferSize, setSoLinger, setSslEngineOptions, setSslHandshakeTimeout, setSslHandshakeTimeoutUnit, setTcpCork, setTcpFastOpen, setTcpKeepAlive, setTcpNoDelay, setTcpQuickAck, setTrafficClass, setUseAlpn`

    - ### Methods inherited from class io.vertx.core.net.ClientOptionsBase

      `getConnectTimeout, getLocalAddress, getMetricsName, getNonProxyHosts, getProxyOptions, isTrustAll, toJson`

    - ### Methods inherited from class io.vertx.core.net.TCPSSLOptions

      `getCrlPaths, getCrlValues, getEnabledCipherSuites, getEnabledSecureTransportProtocols, getIdleTimeout, getIdleTimeoutUnit, getJdkSslEngineOptions, getKeyCertOptions, getKeyStoreOptions, getOpenSslEngineOptions, getPemKeyCertOptions, getPemTrustOptions, getPfxKeyCertOptions, getPfxTrustOptions, getSoLinger, getSslEngineOptions, getSslHandshakeTimeout, getSslHandshakeTimeoutUnit, getTrustOptions, getTrustStoreOptions, isSsl, isTcpCork, isTcpFastOpen, isTcpKeepAlive, isTcpNoDelay, isTcpQuickAck, isUseAlpn`

    - ### Methods inherited from class io.vertx.core.net.NetworkOptions

      `getLogActivity, getReceiveBufferSize, getSendBufferSize, getTrafficClass, isReuseAddress, isReusePort`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### 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

  - ### 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

          public String getWillMessage()

      Returns:
        will message 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

          public MqttClientOptions setWillMessage(String 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

    - #### 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 class `NetClientOptions`
      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

    - #### setIdleTimeout

          @Deprecated
          public MqttClientOptions setIdleTimeout(int idleTimeout)

      Deprecated.
      Do the same thing as `setKeepAliveInterval(int)` (int)}. Use it instead.
      Overrides:
        `setIdleTimeout` in class `NetClientOptions`
      Parameters:
        `idleTimeout` - the timeout, in seconds
      Returns:
        a reference to this, so the API can be used fluently

    - #### setSsl

          public MqttClientOptions setSsl(boolean ssl)

      Description copied from class: `TCPSSLOptions`
      Set whether SSL/TLS is enabled
      Overrides:
        `setSsl` in class `NetClientOptions`
      Parameters:
        `ssl` - true if enabled
      Returns:
        a reference to this, so the API can be used fluently

    - #### setTrustStoreOptions

          public MqttClientOptions setTrustStoreOptions(JksOptions options)

      Description copied from class: `TCPSSLOptions`
      Set the trust options in jks format, aka Java truststore
      Overrides:
        `setTrustStoreOptions` in class `NetClientOptions`
      Parameters:
        `options` - the trust options in jks format
      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 class `NetClientOptions`
      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 class `NetClientOptions`
      Parameters:
        `options` - the key store options
      Returns:
        a reference to this, so the API can be used fluently

    - #### setKeyStoreOptions

          public MqttClientOptions setKeyStoreOptions(JksOptions options)

      Description copied from class: `TCPSSLOptions`
      Set the key/cert options in jks format, aka Java keystore.
      Overrides:
        `setKeyStoreOptions` in class `NetClientOptions`
      Parameters:
        `options` - the key store in jks format
      Returns:
        a reference to this, so the API can be used fluently

    - #### setPfxKeyCertOptions

          public MqttClientOptions setPfxKeyCertOptions(PfxOptions options)

      Description copied from class: `TCPSSLOptions`
      Set the key/cert options in pfx format.
      Overrides:
        `setPfxKeyCertOptions` in class `NetClientOptions`
      Parameters:
        `options` - the key cert options in pfx format
      Returns:
        a reference to this, so the API can be used fluently

    - #### setPemKeyCertOptions

          public MqttClientOptions setPemKeyCertOptions(PemKeyCertOptions options)

      Description copied from class: `TCPSSLOptions`
      Set the key/cert store options in pem format.
      Overrides:
        `setPemKeyCertOptions` in class `NetClientOptions`
      Parameters:
        `options` - the options in pem format
      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 class `NetClientOptions`
      Parameters:
        `options` - the trust options
      Returns:
        a reference to this, so the API can be used fluently

    - #### setPemTrustOptions

          public MqttClientOptions setPemTrustOptions(PemTrustOptions options)

      Description copied from class: `TCPSSLOptions`
      Set the trust options in pem format
      Overrides:
        `setPemTrustOptions` in class `NetClientOptions`
      Parameters:
        `options` - the trust options in pem format
      Returns:
        a reference to this, so the API can be used fluently

    - #### setPfxTrustOptions

          public MqttClientOptions setPfxTrustOptions(PfxOptions options)

      Description copied from class: `TCPSSLOptions`
      Set the trust options in pfx format
      Overrides:
        `setPfxTrustOptions` in class `NetClientOptions`
      Parameters:
        `options` - the trust options in pfx format
      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 class `NetClientOptions`
      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 class `NetClientOptions`
      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 class `NetClientOptions`
      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 class `NetClientOptions`
      Parameters:
        `crlValue` - the value
      Returns:
        a reference to this, so the API can be used fluently
      Throws:
        `NullPointerException`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2021 Eclipse. All rights reserved.