Interface ModifiableOutboundPublish

  • All Superinterfaces:
    PublishPacket

    @DoNotImplement
    public interface ModifiableOutboundPublish
    extends PublishPacket
    A PublishPacket that can be modified for onward delivery. Most changes to the parameters will only alter the message that is sent to the subscriber but not the way HiveMQ is handling the original publish message. For example a message will not be stored as a retained message if it wasn't sent as such. For behavioral changes to the message handling use the PublishInboundInterceptor.
    Since:
    4.2.0, CE 2020.1
    • Method Detail

      • setRetain

        void setRetain​(boolean retain)
        Sets the retain flag. This will not affect whether or not the message is stored as a retained message, it merely alters the retained flag sent to the subscriber.
        Parameters:
        retain - The new retain flag for the publish.
        Since:
        4.2.0, CE 2020.1
      • setTopic

        void setTopic​(@NotNull String topic)
        Sets the topic. This will not change whether the publish topic matches the subscription for which it is sent or not, it merely alters the publish topic that is sent to the subscriber.
        Parameters:
        topic - The new topic for the publish.
        Throws:
        NullPointerException - If the topic is null.
        IllegalArgumentException - If the topic is an empty string.
        IllegalArgumentException - If the topic is invalid for publish messages.
        IllegalArgumentException - If the topic length exceeds the configured length for topics. Default is 65535.
        Since:
        4.2.0, CE 2020.1
      • setPayloadFormatIndicator

        void setPayloadFormatIndicator​(@Nullable PayloadFormatIndicator payloadFormatIndicator)
        Sets the payload format indicator. This setting is only respected for MQTT 5 clients. For MQTT 3.x clients this setting is ignored.
        Parameters:
        payloadFormatIndicator - The new payload format indicator for the publish.
        Since:
        4.2.0, CE 2020.1
      • setMessageExpiryInterval

        void setMessageExpiryInterval​(long messageExpiryInterval)
        Sets the message expiry interval. The original expire interval for this message will still be used, only the value sent to the client is changed. This setting is only respected for MQTT 5 clients. For MQTT 3.x clients this setting is ignored.
        Parameters:
        messageExpiryInterval - The new message expiry interval for the publish.
        Throws:
        IllegalArgumentException - If the message expiry interval is less than zero or more than the configured maximum by HiveMQ.
        Since:
        4.2.0, CE 2020.1
      • setResponseTopic

        void setResponseTopic​(@Nullable String responseTopic)
        Sets the response topic. This setting is only respected for MQTT 5 clients. For MQTT 3.x clients this setting is ignored.
        Parameters:
        responseTopic - The new response topic for the publish.
        Throws:
        IllegalArgumentException - If the response topic is not a valid UTF-8 string.
        IllegalArgumentException - If the response topic exceeds the UTF-8 string length limit.
        Since:
        4.2.0, CE 2020.1
      • setCorrelationData

        void setCorrelationData​(@Nullable ByteBuffer correlationData)
        Sets the correlation data. This setting is only respected for MQTT 5 clients. For MQTT 3.x clients this setting is ignored.
        Parameters:
        correlationData - The new correlation data for the publish.
        Since:
        4.2.0, CE 2020.1
      • setContentType

        void setContentType​(@Nullable String contentType)
        Sets the content type. This setting is only respected for MQTT 5 clients. For MQTT 3.x clients this setting is ignored.
        Parameters:
        contentType - The new content type for the publish.
        Throws:
        IllegalArgumentException - If the content type is not a valid UTF-8 string.
        IllegalArgumentException - If the content type exceeds the UTF-8 string length limit.
        Since:
        4.2.0, CE 2020.1
      • setPayload

        void setPayload​(@NotNull ByteBuffer payload)
        Sets the payload.
        Parameters:
        payload - The new payload for the publish.
        Throws:
        NullPointerException - If payload is null.
        Since:
        4.2.0, CE 2020.1
      • setSubscriptionIdentifiers

        void setSubscriptionIdentifiers​(@NotNull List<@NotNull Integer> subscriptionIdentifiers)
        Set the subscription identifier. This will not affect the identifiers of the original subscription, it merely alters the outgoing publish. This setting is only respected for MQTT 5 clients. For MQTT 3.x clients this setting is ignored.
        Parameters:
        subscriptionIdentifiers - The new subscription identifiers for the publish.
        Throws:
        NullPointerException - If the subscription identifiers list is null.
        NullPointerException - If one ore more of the entries are null.
        Since:
        4.2.0, CE 2020.1