Interface RetainedPublishBuilder
@DoNotImplement public interface RetainedPublishBuilder
This builder must be used to create a
RetainedPublish.
Either from values, from a PublishPacket or a Publish.
Every RetainedPublish built by this builder is fully validated against HiveMQ configuration.
- Since:
- 4.0.0, CE 2019.1
-
Method Summary
-
Method Details
-
fromPublish
Create aRetainedPublishfrom the values of aPublishPacket.- Parameters:
publishPacket- The publish packet to build aPublishfrom.- Returns:
- The
RetainedPublishBuilder. - Throws:
NullPointerException- If the publish packet is null.DoNotImplementException- If thePublishPacketis implemented by the extension.- Since:
- 4.0.0, CE 2019.1
-
fromPublish
Create aRetainedPublishfrom the values of aPublish.- Parameters:
publish- The publish to build aPublishfrom.- Returns:
- The
RetainedPublishBuilder. - Throws:
NullPointerException- If the publish is null.DoNotImplementException- If thePublishis implemented by the extension.- Since:
- 4.0.0, CE 2019.1
-
qos
Sets the quality of service.DEFAULT:
QoS 0.- Parameters:
qos- TheQosto set.- Returns:
- The
RetainedPublishBuilder. - Throws:
NullPointerException- If the qos is null.IllegalArgumentException- If qos is higher than the maximum configured qos by HiveMQ. Default is QoS 2.- Since:
- 4.0.0, CE 2019.1
-
topic
Sets the topic.This value has no default and must be set.
- Parameters:
topic- The topic to set.- Returns:
- The
RetainedPublishBuilder. - 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.0.0, CE 2019.1
-
payloadFormatIndicator
@NotNull @NotNull RetainedPublishBuilder payloadFormatIndicator(@Nullable PayloadFormatIndicator payloadFormatIndicator)Sets the payload format indicator.DEFAULT:
null.- Parameters:
payloadFormatIndicator- The payload format indicator to set.- Returns:
- The
RetainedPublishBuilder. - Since:
- 4.0.0, CE 2019.1
-
messageExpiryInterval
Sets the message expiry interval in seconds.DEFAULT:
no expiry.The default can be changed by configuring
<message-expiry>in the<mqtt>config in the config.xml.- Parameters:
messageExpiryInterval- The message expiry interval to set.- Returns:
- The
RetainedPublishBuilder. - Throws:
IllegalArgumentException- If the message expiry interval is less than zero or more than the configured maximum by HiveMQ. Default is no expiry.- Since:
- 4.0.0, CE 2019.1
-
responseTopic
Sets the response topic.DEFAULT:
null.- Parameters:
responseTopic- The response topic to set.- Returns:
- The
RetainedPublishBuilder. - 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.0.0, CE 2019.1
-
correlationData
Sets the correlation data.DEFAULT:
null.- Parameters:
correlationData- The correlation data to set.- Returns:
- The
RetainedPublishBuilder. - Since:
- 4.0.0, CE 2019.1
-
contentType
Sets the content type.DEFAULT:
null.- Parameters:
contentType- The content type to set.- Returns:
- The
RetainedPublishBuilder. - 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.0.0, CE 2019.1
-
payload
Sets the payload.This value has no default and must be set.
- Parameters:
payload- The payload to set.- Returns:
- The
RetainedPublishBuilder. - Throws:
NullPointerException- If the payload is null.- Since:
- 4.0.0, CE 2019.1
-
userProperty
Adds a user property.DEFAULT:
empty list.- Parameters:
key- The key of the user property to add.value- The value of the user property to add.- Returns:
- The
RetainedPublishBuilder. - Throws:
NullPointerException- If the key or the value is null.IllegalArgumentException- If the key or value is not a valid UTF-8 string.IllegalArgumentException- If the key or value exceeds the UTF-8 string length limit.- Since:
- 4.0.0, CE 2019.1
-
build
Builds theRetainedPublishwith the provided values or default values.- Returns:
- A
RetainedPublishwith the set parameters. - Throws:
NullPointerException- If the topic or the payload is null.- Since:
- 4.0.0, CE 2019.1
-