Package io.vertx.mqtt

Class MqttClientOptions


  • public class MqttClientOptions
    extends NetClientOptions
    Represents options used by the MQTT client.
    • 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 via MqttPublishMessage#ack(). If true, the ack (PUBACK/PUBCOMP) will be sent by vertx-mqtt before MqttClient#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 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
      • 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
      • 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 class NetClientOptions
        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 class NetClientOptions
        Parameters:
        trustAll - true if all should be trusted
        Returns:
        a reference to this, so the API can be used fluently