Package io.micronaut.mqtt.hivemq.bind
Class MqttMessage
java.lang.Object
io.micronaut.mqtt.hivemq.bind.MqttMessage
A MQTT message holds the payload and options
for message delivery.
- Since:
- 3.0.0
- Author:
- Sven Kobow
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns a string describing the content type.byte[]
Returns the correlation data for the message.int
getId()
Returns the message id.long
Returns the message expiry interval in seconds.byte[]
Returns the payload as byte array.int
Returns the payload format indicator.int
getQos()
Returns the quality of service level for the message.Returns the response topic for using MQTT v5 request response pattern.Returns the MQTT user properties.boolean
Returns whether the message is a retained message.void
setContentType
(String contentType) Sets the content type description for the message.void
setCorrelationData
(byte[] correlationData) Sets the correlation data for the message.void
setId
(int messageId) Sets the message id.void
setMessageExpiryInterval
(long messageExpiryInterval) Sets the message expiry interval in seconds.void
setPayload
(byte[] payload) Sets the payload of the message.void
setPayloadFormatIndicator
(int payloadFormatIndicator) Sets the payload format indicator.void
setQos
(int qos) Sets the quality of service level for the message.void
setResponseTopic
(String responseTopic) Sets the response topic for using MQTT v5 request response pattern.void
setRetained
(boolean retained) Sets whether the message is retained.void
setUserProperties
(List<UserProperty> userProperties) Sets the MQTT user properties.
-
Constructor Details
-
MqttMessage
public MqttMessage() -
MqttMessage
public MqttMessage(byte[] payload)
-
-
Method Details
-
getPayload
public byte[] getPayload()Returns the payload as byte array.- Returns:
- payload The payload byte array.
-
setPayload
public void setPayload(byte[] payload) Sets the payload of the message.- Parameters:
payload
- The payload as byte array.
-
getPayloadFormatIndicator
public int getPayloadFormatIndicator()Returns the payload format indicator. 0 = unspecified byte stream 1 = UTF-8 encoded payload- Returns:
- The MQTT payload indicator.
-
setPayloadFormatIndicator
public void setPayloadFormatIndicator(int payloadFormatIndicator) Sets the payload format indicator.- Parameters:
payloadFormatIndicator
- Use 0 for unspecified byte stream and 1 for UTF-8 encoded payload.
-
getQos
public int getQos()Returns the quality of service level for the message.- Returns:
- MQTT quality of service level.
-
setQos
public void setQos(int qos) Sets the quality of service level for the message.- Parameters:
qos
- MQTT quality of service level.
-
isRetained
public boolean isRetained()Returns whether the message is a retained message.- Returns:
- boolean value.
-
setRetained
public void setRetained(boolean retained) Sets whether the message is retained.- Parameters:
retained
- boolean value.
-
getId
public int getId()Returns the message id.- Returns:
- message id.
-
setId
public void setId(int messageId) Sets the message id.- Parameters:
messageId
- message id.
-
setUserProperties
Sets the MQTT user properties.- Parameters:
userProperties
- MQTT user properties.
-
getUserProperties
Returns the MQTT user properties.- Returns:
- MQTT user properties.
-
getCorrelationData
public byte[] getCorrelationData()Returns the correlation data for the message.- Returns:
- the correlation data.
-
setCorrelationData
public void setCorrelationData(byte[] correlationData) Sets the correlation data for the message.- Parameters:
correlationData
- the correlation data.
-
getContentType
Returns a string describing the content type.- Returns:
- A string describing the content type.
- See Also:
-
payloadFormatIndicator
-
setContentType
Sets the content type description for the message.- Parameters:
contentType
- A string describing the content type.
-
getMessageExpiryInterval
public long getMessageExpiryInterval()Returns the message expiry interval in seconds.- Returns:
- The message expiry interval in seconds.
-
setMessageExpiryInterval
public void setMessageExpiryInterval(long messageExpiryInterval) Sets the message expiry interval in seconds.- Parameters:
messageExpiryInterval
- The message expiry interval in seconds.
-
getResponseTopic
Returns the response topic for using MQTT v5 request response pattern.- Returns:
- The response topic.
-
setResponseTopic
Sets the response topic for using MQTT v5 request response pattern.- Parameters:
responseTopic
- The reponse topic.
-