Class MqttMessage


  • public final class MqttMessage
    extends Object
    Represents a message to publish, or a message that was received.
    • Constructor Detail

      • MqttMessage

        public MqttMessage​(String topic,
                           byte[] payload,
                           QualityOfService qos,
                           boolean retain,
                           boolean dup)
        Constructs a new message.
        Parameters:
        topic - Message topic.
        payload - Message payload.
        qos - QualityOfService. When sending, the QualityOfService to use for delivery. When receiving, the QualityOfService used for delivery.
        retain - Retain flag. When sending, whether the message should be retained by the broker and delivered to future subscribers. When receiving, whether the message was sent as a result of a new subscription being made.
        dup - DUP flag. Ignored when sending. When receiving, indicates whether this might be re-delivery of an earlier attempt to send the message.
      • MqttMessage

        public MqttMessage​(String topic,
                           byte[] payload,
                           QualityOfService qos,
                           boolean retain)
        Constructs a new message.
        Parameters:
        topic - Message topic.
        payload - Message payload.
        qos - QualityOfService. When sending, the QualityOfService to use for delivery. When receiving, the QualityOfService used for delivery.
        retain - Retain flag. When sending, whether the message should be retained by the broker and delivered to future subscribers. When receiving, whether the message was sent as a result of a new subscription being made.
      • MqttMessage

        @Deprecated
        public MqttMessage​(String topic,
                           byte[] payload)
        Deprecated.
        Use alternate constructor.
    • Method Detail

      • getTopic

        public String getTopic()
        Gets the topic associated with this message
        Returns:
        The topic
      • getPayload

        public byte[] getPayload()
        Gets the message payload
        Returns:
        Message payload
      • getRetain

        public boolean getRetain()
        Gets the retain flag. When sending, whether the message should be retained by the broker and delivered to future subscribers. When receiving, whether the message was sent as a result of a new subscription being made.
        Returns:
        Retain flag
      • getDup

        public boolean getDup()
        Gets the DUP flag. Ignored when sending. When receiving, indicates whether this might be re-delivery of an earlier attempt to send the message.
        Returns:
        DUP flag