Class PublishPacket.PublishPacketBuilder
- java.lang.Object
-
- software.amazon.awssdk.crt.mqtt5.packets.PublishPacket.PublishPacketBuilder
-
- Enclosing class:
- PublishPacket
public static final class PublishPacket.PublishPacketBuilder extends Object
A class to that allows for the creation of a PublishPacket. Set all of the settings you want in the packet and then use the build() function to get a PublishPacket populated with the settings defined in the builder.
-
-
Constructor Summary
Constructors Constructor Description PublishPacketBuilder()
Creates a new PublishPacketBuilder so a PublishPacket can be created.PublishPacketBuilder(String topic, QOS packetQOS, byte[] payload)
Creates a new PublishPacketBuilder with common parameters set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PublishPacket
build()
Creates a new PublishPacket using the settings set in the builder.PublishPacket.PublishPacketBuilder
withContentType(String contentType)
Sets the property specifying the content type of the payload.PublishPacket.PublishPacketBuilder
withCorrelationData(byte[] correlationData)
Sets the opaque binary data used to correlate between publish messages, as a potential method for request-response implementation.PublishPacket.PublishPacketBuilder
withMessageExpiryIntervalSeconds(Long messageExpiryIntervalSeconds)
Sets the maximum amount of time allowed to elapse for message delivery before the server should instead delete the message (relative to a recipient).PublishPacket.PublishPacketBuilder
withPayload(byte[] payload)
Sets the payload for the publish message.PublishPacket.PublishPacketBuilder
withPayloadFormat(PublishPacket.PayloadFormatIndicator payloadFormat)
Sets the property specifying the format of the payload data.PublishPacket.PublishPacketBuilder
withQOS(QOS packetQOS)
Sets the MQTT quality of service level the message should be delivered with.PublishPacket.PublishPacketBuilder
withResponseTopic(String responseTopic)
Sets the opaque topic string intended to assist with request/response implementations.PublishPacket.PublishPacketBuilder
withRetain(Boolean retain)
Sets if this should be a retained message.PublishPacket.PublishPacketBuilder
withTopic(String topic)
Sets the topic this message should be published to.PublishPacket.PublishPacketBuilder
withTopicAlias(long topicAlias)
Sets the topic alias to use when sending this publish.PublishPacket.PublishPacketBuilder
withUserProperties(List<UserProperty> userProperties)
Sets the list of MQTT5 user properties included with the packet.
-
-
-
Constructor Detail
-
PublishPacketBuilder
public PublishPacketBuilder()
Creates a new PublishPacketBuilder so a PublishPacket can be created.
-
PublishPacketBuilder
public PublishPacketBuilder(String topic, QOS packetQOS, byte[] payload)
Creates a new PublishPacketBuilder with common parameters set.- Parameters:
topic
- The topic this message should be published to.packetQOS
- The MQTT quality of service level the message should be delivered with.payload
- The payload for the publish message.
-
-
Method Detail
-
withPayload
public PublishPacket.PublishPacketBuilder withPayload(byte[] payload)
Sets the payload for the publish message. See MQTT5 Publish Payload- Parameters:
payload
- The payload for the publish message.- Returns:
- The PublishPacketBuilder after setting the payload.
-
withQOS
public PublishPacket.PublishPacketBuilder withQOS(QOS packetQOS)
Sets the MQTT quality of service level the message should be delivered with. See MQTT5 QoS- Parameters:
packetQOS
- The MQTT quality of service level the message should be delivered with.- Returns:
- The PublishPacketBuilder after setting the QOS.
-
withRetain
public PublishPacket.PublishPacketBuilder withRetain(Boolean retain)
Sets if this should be a retained message. Null implies false. See MQTT5 Retain- Parameters:
retain
- if this is a retained message.- Returns:
- The PublishPacketBuilder after setting the retain setting.
-
withTopic
public PublishPacket.PublishPacketBuilder withTopic(String topic)
Sets the topic this message should be published to. See MQTT5 Topic Name- Parameters:
topic
- The topic this message should be published to.- Returns:
- The PublishPacketBuilder after setting the topic.
-
withPayloadFormat
public PublishPacket.PublishPacketBuilder withPayloadFormat(PublishPacket.PayloadFormatIndicator payloadFormat)
Sets the property specifying the format of the payload data. The Mqtt5Client does not enforce or use this value in a meaningful way. See MQTT5 Payload Format Indicator- Parameters:
payloadFormat
- Property specifying the format of the payload data- Returns:
- The PublishPacketBuilder after setting the payload format.
-
withMessageExpiryIntervalSeconds
public PublishPacket.PublishPacketBuilder withMessageExpiryIntervalSeconds(Long messageExpiryIntervalSeconds)
Sets the maximum amount of time allowed to elapse for message delivery before the server should instead delete the message (relative to a recipient). If left null, indicates no expiration timeout. See MQTT5 Message Expiry Interval- Parameters:
messageExpiryIntervalSeconds
- The maximum amount of time allowed to elapse for message delivery before the server should instead delete the message (relative to a recipient).- Returns:
- The PublishPacketBuilder after setting the message expiry interval.
-
withTopicAlias
public PublishPacket.PublishPacketBuilder withTopicAlias(long topicAlias)
Sets the topic alias to use when sending this publish. Will only be used if the outbound topic aliasing behavior has been set to Manual. See MQTT5 Topic Alias- Parameters:
topicAlias
- alias value to use. Must be greater than 0 and less than 65536.- Returns:
- The PublishPacketBuilder after setting the topic alias.
-
withResponseTopic
public PublishPacket.PublishPacketBuilder withResponseTopic(String responseTopic)
Sets the opaque topic string intended to assist with request/response implementations. Not internally meaningful to MQTT5 or this client. See MQTT5 Response Topic- Parameters:
responseTopic
- Topic string intended to assist with request/response implementations- Returns:
- The PublishPacketBuilder after setting the response topic.
-
withCorrelationData
public PublishPacket.PublishPacketBuilder withCorrelationData(byte[] correlationData)
Sets the opaque binary data used to correlate between publish messages, as a potential method for request-response implementation. Not internally meaningful to MQTT5. See MQTT5 Correlation Data- Parameters:
correlationData
- Opaque binary data used to correlate between publish messages- Returns:
- The PublishPacketBuilder after setting the correlation data.
-
withContentType
public PublishPacket.PublishPacketBuilder withContentType(String contentType)
Sets the property specifying the content type of the payload. Not internally meaningful to MQTT5. See MQTT5 Content Type- Parameters:
contentType
- Property specifying the content type of the payload- Returns:
- The PublishPacketBuilder after setting the content type.
-
withUserProperties
public PublishPacket.PublishPacketBuilder withUserProperties(List<UserProperty> userProperties)
Sets the list of MQTT5 user properties included with the packet. See MQTT5 User Property- Parameters:
userProperties
- List of MQTT5 user properties included with the packet.- Returns:
- The PublishPacketBuilder after setting the user properties.
-
build
public PublishPacket build()
Creates a new PublishPacket using the settings set in the builder.- Returns:
- The PublishPacket created from the builder
-
-