Class MqttClientWillOptions
java.lang.Object
io.vertx.mqtt.MqttClientWillOptions
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final boolean -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Create instance from JSON (delegates to generated converter).Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionaddUserProperty(String key, String value) Add a single User Property.intgetQos()getTopic()booleanisRetain()setContentType(String contentType) Set the Content Type (MIME type) that describes the will payload.setCorrelationData(Buffer correlationData) Set the Correlation Data used to correlate a request/response.setMessageBytes(Buffer messageBytes) Set the will message payload.setPayloadFormatIndicator(Integer payloadFormatIndicator) Set the Payload Format Indicator.setQos(int qos) Set the QoS level for the will message.setResponseTopic(String responseTopic) Set the Response Topic used in a request/response pattern.setRetain(boolean retain) Set whether the will message must be retained.Set the topic on which the will message will be published.setUserProperties(Map<String, String> userProperties) Set the User Properties.setWillDelayInterval(Long willDelayInterval) Set the Will Delay Interval.toJson()Convert instance to JSON (delegates to generated converter).toString()
-
Field Details
-
DEFAULT_WILL_QOS
public static final int DEFAULT_WILL_QOS- See Also:
-
DEFAULT_WILL_RETAIN
public static final boolean DEFAULT_WILL_RETAIN- See Also:
-
-
Constructor Details
-
MqttClientWillOptions
public MqttClientWillOptions()Default constructor. -
MqttClientWillOptions
Copy constructor. -
MqttClientWillOptions
Create instance from JSON (delegates to generated converter).
-
-
Method Details
-
toJson
Convert instance to JSON (delegates to generated converter). -
getTopic
- Returns:
- topic on which the will message will be published
-
setTopic
Set the topic on which the will message will be published.- Parameters:
topic- will topic- Returns:
- this options instance
-
getMessageBytes
- Returns:
- will message payload bytes
-
setMessageBytes
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
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
Set whether the will message must be retained.- Parameters:
retain- true to retain the will message- Returns:
- this options instance
-
getWillDelayInterval
- Returns:
- Will Delay Interval in seconds, or null if not set (MQTT 5.0)
-
setWillDelayInterval
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
- Returns:
- Payload Format Indicator (0=bytes, 1=UTF-8), or null if not set (MQTT 5.0)
-
setPayloadFormatIndicator
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
- Returns:
- Content Type (MIME type) of the will payload, or null if not set (MQTT 5.0)
-
setContentType
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
- Returns:
- Response Topic for request/response pattern, or null if not set (MQTT 5.0)
-
setResponseTopic
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
- Returns:
- Correlation Data used to correlate a request, or null if not set (MQTT 5.0)
-
setCorrelationData
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
-
setUserProperties
Set the User Properties. (MQTT 5.0 only)- Parameters:
userProperties- map of key-value pairs, or null to unset- Returns:
- this options instance
-
addUserProperty
Add a single User Property. (MQTT 5.0 only)- Parameters:
key- property keyvalue- property value- Returns:
- this options instance
-
toString
-