Class MqttClientWillOptions

java.lang.Object
io.vertx.mqtt.MqttClientWillOptions

public class MqttClientWillOptions extends Object
Options for the MQTT Last Will and Testament (LWT) message.

Supports both MQTT 3.1.1 (topic, payload, QoS, retain) and MQTT 5.0 additional properties (Will Delay Interval, Payload Format Indicator, Content Type, Response Topic, Correlation Data, User Properties).

  • Field Details

  • Constructor Details

    • MqttClientWillOptions

      public MqttClientWillOptions()
      Default constructor.
    • MqttClientWillOptions

      public MqttClientWillOptions(MqttClientWillOptions other)
      Copy constructor.
    • MqttClientWillOptions

      public MqttClientWillOptions(JsonObject json)
      Create instance from JSON (delegates to generated converter).
  • Method Details

    • toJson

      public JsonObject toJson()
      Convert instance to JSON (delegates to generated converter).
    • getTopic

      public String getTopic()
      Returns:
      topic on which the will message will be published
    • setTopic

      public MqttClientWillOptions setTopic(String topic)
      Set the topic on which the will message will be published.
      Parameters:
      topic - will topic
      Returns:
      this options instance
    • getMessageBytes

      public Buffer getMessageBytes()
      Returns:
      will message payload bytes
    • setMessageBytes

      public MqttClientWillOptions setMessageBytes(Buffer messageBytes)
      Set the will message payload.
      Parameters:
      messageBytes - will payload
      Returns:
      this options instance
    • getQos

      public int getQos()
      Returns:
      QoS level for the will message (0, 1 or 2)
    • setQos

      public MqttClientWillOptions setQos(int qos)
      Set the QoS level for the will message.
      Parameters:
      qos - QoS level (0, 1 or 2)
      Returns:
      this options instance
    • isRetain

      public boolean isRetain()
      Returns:
      whether the will message must be retained
    • setRetain

      public MqttClientWillOptions setRetain(boolean retain)
      Set whether the will message must be retained.
      Parameters:
      retain - true to retain the will message
      Returns:
      this options instance
    • getWillDelayInterval

      public Long getWillDelayInterval()
      Returns:
      Will Delay Interval in seconds, or null if not set (MQTT 5.0)
    • setWillDelayInterval

      public MqttClientWillOptions setWillDelayInterval(Long willDelayInterval)
      Set the Will Delay Interval.

      The broker delays publishing the will message until this interval (in seconds) elapses after the network connection is closed, or until the session ends. If null, the broker publishes the will message immediately. (MQTT 5.0 only)

      Parameters:
      willDelayInterval - delay in seconds (0..4294967295), or null to unset
      Returns:
      this options instance
    • getPayloadFormatIndicator

      public Integer getPayloadFormatIndicator()
      Returns:
      Payload Format Indicator (0=bytes, 1=UTF-8), or null if not set (MQTT 5.0)
    • setPayloadFormatIndicator

      public MqttClientWillOptions setPayloadFormatIndicator(Integer payloadFormatIndicator)
      Set the Payload Format Indicator.

      0 means the will payload is unspecified bytes; 1 means it is UTF-8 encoded. (MQTT 5.0 only)

      Parameters:
      payloadFormatIndicator - 0 or 1, or null to unset
      Returns:
      this options instance
    • getContentType

      public String getContentType()
      Returns:
      Content Type (MIME type) of the will payload, or null if not set (MQTT 5.0)
    • setContentType

      public MqttClientWillOptions setContentType(String contentType)
      Set the Content Type (MIME type) that describes the will payload. (MQTT 5.0 only)
      Parameters:
      contentType - MIME type string, or null to unset
      Returns:
      this options instance
    • getResponseTopic

      public String getResponseTopic()
      Returns:
      Response Topic for request/response pattern, or null if not set (MQTT 5.0)
    • setResponseTopic

      public MqttClientWillOptions setResponseTopic(String responseTopic)
      Set the Response Topic used in a request/response pattern. (MQTT 5.0 only)
      Parameters:
      responseTopic - topic name, or null to unset
      Returns:
      this options instance
    • getCorrelationData

      public Buffer getCorrelationData()
      Returns:
      Correlation Data used to correlate a request, or null if not set (MQTT 5.0)
    • setCorrelationData

      public MqttClientWillOptions setCorrelationData(Buffer correlationData)
      Set the Correlation Data used to correlate a request/response. (MQTT 5.0 only)
      Parameters:
      correlationData - binary data, or null to unset
      Returns:
      this options instance
    • getUserProperties

      public Map<String,String> getUserProperties()
      Returns:
      User Properties as key-value pairs, or null if not set (MQTT 5.0)
    • setUserProperties

      public MqttClientWillOptions setUserProperties(Map<String,String> userProperties)
      Set the User Properties. (MQTT 5.0 only)
      Parameters:
      userProperties - map of key-value pairs, or null to unset
      Returns:
      this options instance
    • addUserProperty

      public MqttClientWillOptions addUserProperty(String key, String value)
      Add a single User Property. (MQTT 5.0 only)
      Parameters:
      key - property key
      value - property value
      Returns:
      this options instance
    • toString

      public String toString()
      Overrides:
      toString in class Object