Class MqttMessage

java.lang.Object
io.micronaut.mqtt.hivemq.bind.MqttMessage

public class MqttMessage extends Object
A MQTT message holds the payload and options for message delivery.
Since:
3.0.0
Author:
Sven Kobow
  • 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

      public void setUserProperties(List<UserProperty> userProperties)
      Sets the MQTT user properties.
      Parameters:
      userProperties - MQTT user properties.
    • getUserProperties

      public List<UserProperty> 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

      public String getContentType()
      Returns a string describing the content type.
      Returns:
      A string describing the content type.
      See Also:
      • payloadFormatIndicator
    • setContentType

      public void setContentType(String contentType)
      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

      public String getResponseTopic()
      Returns the response topic for using MQTT v5 request response pattern.
      Returns:
      The response topic.
    • setResponseTopic

      public void setResponseTopic(String responseTopic)
      Sets the response topic for using MQTT v5 request response pattern.
      Parameters:
      responseTopic - The reponse topic.