Interface PublishPacket

All Known Subinterfaces:
ModifiableOutboundPublish, ModifiablePublishPacket, ModifiableWillPublish, WillPublishPacket

@Immutable
@DoNotImplement
public interface PublishPacket
Represents a PUBLISH packet.

Contains all values of an MQTT 5 PUBLISH, but will also used to represent MQTT 3 publishes.

Since:
4.0.0, CE 2019.1
  • Method Details

    • getDupFlag

      boolean getDupFlag()
      If false this is the first occasion the message is sent to the receiver. If true the message has already been sent once to the receiver.
      Returns:
      The duplicate delivery flag.
      Since:
      4.0.0, CE 2019.1
    • getQos

      The quality of service level of the publish.
      Returns:
      The qos.
      Since:
      4.0.0, CE 2019.1
    • getRetain

      boolean getRetain()
      If true this message is a retained message, for false this is just a normal publish.
      Returns:
      The retain flag.
      Since:
      4.0.0, CE 2019.1
    • getTopic

      The topic filter the message is published to.
      Returns:
      The topic.
      Since:
      4.0.0, CE 2019.1
    • getPacketId

      int getPacketId()
      The packet identifier of the publish.
      Returns:
      The packet identifier.
      Since:
      4.0.0, CE 2019.1
    • getPayloadFormatIndicator

      @NotNull @NotNull Optional<PayloadFormatIndicator> getPayloadFormatIndicator()
      If this property is present, this is the payload format indicator.

      For an MQTT 3 PUBLISH this MQTT 5 property will always be empty.

      Returns:
      An Optional that contains the payload format indicator if present.
      Since:
      4.0.0, CE 2019.1
    • getMessageExpiryInterval

      @NotNull @NotNull Optional<Long> getMessageExpiryInterval()
      If this property is present, this is the message expiry interval.

      For an MQTT 3 PUBLISH this MQTT 5 property will always have the value from the configured message expiry.

      Returns:
      An Optional that contains the message expiry interval if present.
      Since:
      4.0.0, CE 2019.1
    • getResponseTopic

      @NotNull @NotNull Optional<String> getResponseTopic()
      If this property is present, this is the response topic.

      For an MQTT 3 PUBLISH this MQTT 5 property will always be empty.

      Returns:
      An Optional that contains the response topic if present.
      Since:
      4.0.0, CE 2019.1
    • getCorrelationData

      If this property is present, this is the correlation data.

      For an MQTT 3 PUBLISH this MQTT 5 property will always be empty.

      The ByteBuffer returned by this method is read only and will throw a ReadOnlyBufferException if handled incorrectly.

      Returns:
      An Optional that contains the correlation data if present.
      Since:
      4.0.0, CE 2019.1
    • getSubscriptionIdentifiers

      @Immutable @NotNull @Immutable @NotNull List<@NotNull Integer> getSubscriptionIdentifiers()
      The list of subscription identifiers for PUBLISH.

      For an MQTT 3 PUBLISH this MQTT 5 property will always be an empty list.

      Returns:
      The subscription identifiers.
      Since:
      4.0.0, CE 2019.1
    • getContentType

      @NotNull @NotNull Optional<String> getContentType()
      If this property is present, this is the content type.

      For an MQTT 3 PUBLISH this MQTT 5 property will always be empty.

      Returns:
      An Optional that contains the content type if present.
      Since:
      4.0.0, CE 2019.1
    • getPayload

      If this property is present, this is the payload.

      The ByteBuffer returned by this method is read only and will throw a ReadOnlyBufferException if handled incorrectly.

      Returns:
      An Optional that contains the payload if present.
      Since:
      4.0.0, CE 2019.1
    • getUserProperties

      The UserProperties of the PUBLISH.

      For an MQTT 3 PUBLISH this MQTT 5 property will always be an empty list.

      Returns:
      The user properties.
      Since:
      4.0.0, CE 2019.1
    • getTimestamp

      long getTimestamp()
      The arrival timestamp of the PUBLISH.

      For an incoming PUBLISH message the timestamp represents the moment when the message arrived at the broker.

      For a message created via the Extension SDK the timestamp represents the moment when the message is passed to the PublishService.

      For a Will Publish that is sent to subscribers, the timestamp represents the moment when the delivery started (after the client disconnected ungracefully and the Will delay has passed).

      The returned timestamp is a UNIX timestamp since midnight, January 1, 1970 UTC in milliseconds.

      Returns:
      The timestamp.
      Since:
      4.4.0, CE 2020.4