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 Summary
Modifier and Type Method Description @NotNull ModifiableUserPropertiesgetUserProperties()Get the modifiableUserPropertiesof the PUBLISH packet.voidsetContentType(@Nullable String contentType)Sets the content type.voidsetCorrelationData(@Nullable ByteBuffer correlationData)Sets the correlation data.voidsetMessageExpiryInterval(long messageExpiryInterval)Sets the message expiry interval.voidsetPayload(@NotNull ByteBuffer payload)Sets the payload.voidsetPayloadFormatIndicator(@Nullable PayloadFormatIndicator payloadFormatIndicator)Sets the payload format indicator.voidsetResponseTopic(@Nullable String responseTopic)Sets the response topic.voidsetRetain(boolean retain)Sets the retain flag.voidsetSubscriptionIdentifiers(@NotNull List<@NotNull Integer> subscriptionIdentifiers)Set the subscription identifier.voidsetTopic(@NotNull String topic)Sets the topic.Methods inherited from interface com.hivemq.extension.sdk.api.packets.publish.PublishPacket
getContentType, getCorrelationData, getDupFlag, getMessageExpiryInterval, getPacketId, getPayload, getPayloadFormatIndicator, getQos, getResponseTopic, getRetain, getSubscriptionIdentifiers, getTimestamp, getTopic
-
Method Details
-
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
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
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
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
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
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
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
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
-
getUserProperties
Get the modifiableUserPropertiesof the PUBLISH packet.- Specified by:
getUserPropertiesin interfacePublishPacket- Returns:
- Modifiable user properties.
- Since:
- 4.2.0, CE 2020.1
-