Class PublishPacket

java.lang.Object
software.amazon.awssdk.crt.mqtt5.packets.PublishPacket

public class PublishPacket extends Object
Data model of an MQTT5 PUBLISH packet
  • Method Details

    • getPayload

      public byte[] getPayload()
      Returns the payload of the publish message. See MQTT5 Publish Payload
      Returns:
      The payload of the publish message.
    • getQOS

      public QOS getQOS()
      Sent publishes - Returns the MQTT quality of service level this message should be delivered with. Received publishes - Returns the MQTT quality of service level this message was delivered at. See MQTT5 QoS
      Returns:
      The MQTT quality of service associated with this PUBLISH packet.
    • getRetain

      public Boolean getRetain()
      Returns true if this is a retained message, false otherwise. Always set on received publishes; on sent publishes, null implies false. See MQTT5 Retain
      Returns:
      True if this is a retained message, false otherwise.
    • getTopic

      public String getTopic()
      Sent publishes - Returns the topic this message should be published to. Received publishes - Returns the topic this message was published to. See MQTT5 Topic Name
      Returns:
      The topic associated with this PUBLISH packet.
    • getPayloadFormat

      public PublishPacket.PayloadFormatIndicator getPayloadFormat()
      Returns the property specifying the format of the payload data. The Mqtt5Client does not enforce or use this value in a meaningful way. See MQTT5 Payload Format Indicator
      Returns:
      Property specifying the format of the payload data.
    • getMessageExpiryIntervalSeconds

      public Long getMessageExpiryIntervalSeconds()
      Sent publishes - Returns the maximum amount of time allowed to elapse for message delivery before the server should instead delete the message (relative to a recipient). Received publishes - Returns the remaining amount of time (from the server's perspective) before the message would have been deleted relative to the subscribing client. If left null, indicates no expiration timeout. See MQTT5 Message Expiry Interval
      Returns:
      The message expiry interval associated with this PublishPacket.
    • getTopicAlias

      public Long getTopicAlias()
      Sent publishes - topic alias to use, if possible, when encoding this packet. Only used if the client's outbound topic aliasing mode is set to Manual. Received publishes - topic alias used by the server when transmitting the publish to the client. See MQTT5 Topic Alias
      Returns:
      The topic alias associated with this PublishPacket.
    • getResponseTopic

      public String getResponseTopic()
      Returns a opaque topic string intended to assist with request/response implementations. Not internally meaningful to MQTT5 or this client. See MQTT5 Response Topic
      Returns:
      Opaque topic string intended to assist with request/response implementations.
    • getCorrelationData

      public byte[] getCorrelationData()
      Returns a opaque binary data used to correlate between publish messages, as a potential method for request-response implementation. Not internally meaningful to MQTT5. See MQTT5 Correlation Data
      Returns:
      Opaque binary data used to correlate between publish messages.
    • getContentType

      public String getContentType()
      Returns a property specifying the content type of the payload. Not internally meaningful to MQTT5. See MQTT5 Content Type
      Returns:
      Property specifying the content type of the payload.
    • getUserProperties

      public List<UserProperty> getUserProperties()
      Returns a list of MQTT5 user properties included with the packet. See MQTT5 User Property
      Returns:
      List of MQTT5 user properties included with the packet.
    • getSubscriptionIdentifiers

      public List<Long> getSubscriptionIdentifiers()
      Sent publishes - Ignored Received publishes - Returns the subscription identifiers of all the subscriptions this message matched. See MQTT5 Subscription Identifier
      Returns:
      the subscription identifiers of all the subscriptions this message matched.
    • of

      public static PublishPacket of(String topic, QOS qos, byte[] payload)
      Creates a PublishPacket containing only the most common fields: topic, QoS, and payload.

      Internally this is just syntactic sugar around PublishPacketBuilder(String, QOS, byte[]) followed by PublishPacket.PublishPacketBuilder.build(). All optional MQTT 5 properties (retain flag, user properties, etc.) are left null / unset.

      Parameters:
      topic - The topic this message should be published to.
      qos - The MQTT quality of service level the message should be delivered with.
      payload - The payload for the publish message.
      Returns:
      an immutable PublishPacket ready for use
      Throws:
      NullPointerException - if topic, qos, or payload is null