Package software.amazon.awssdk.crt.mqtt5
Class Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
- java.lang.Object
-
- software.amazon.awssdk.crt.mqtt5.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
-
- Enclosing class:
- Mqtt5ClientOptions
public static final class Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder extends Object
All of the options for a Mqtt5Client. This includes the settings to make a connection, as well as the event callbacks, publish callbacks, and more.
-
-
Constructor Summary
Constructors Constructor Description Mqtt5ClientOptionsBuilder(String hostName, Long port)
Creates a new Mqtt5ClientOptionsBuilder instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Mqtt5ClientOptions
build()
Returns a Mqtt5ClientOptions class configured with all of the options set in the Mqtt5ClientOptionsBuilder.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withAckTimeoutSeconds(Long ackTimeoutSeconds)
Sets the time interval to wait for an ack after sending a QoS 1+ PUBLISH, SUBSCRIBE, or UNSUBSCRIBE before failing the operation.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withBootstrap(ClientBootstrap bootstrap)
Sets the ClientBootstrap to use.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withConnackTimeoutMs(Long connackTimeoutMs)
Sets the time interval to wait after sending a CONNECT request for a CONNACK to arrive.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withConnectOptions(ConnectPacket connectOptions)
Sets all configurable options with respect to the CONNECT packet sent by the client, including the Will.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withExtendedValidationAndFlowControlOptions(Mqtt5ClientOptions.ExtendedValidationAndFlowControlOptions extendedValidationAndFlowControlOptions)
Sets the additional controls for client behavior with respect to operation validation and flow control; these checks go beyond the base MQTT5 spec to respect limits of specific MQTT brokers.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withHostName(String hostName)
Sets the host name of the MQTT server to connect to.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withHttpProxyOptions(HttpProxyOptions httpProxyOptions)
Sets the (tunneling) HTTP proxy usage when establishing MQTT connection.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withLifecycleEvents(Mqtt5ClientOptions.LifecycleEvents lifecycleEvents)
Sets the Lifecycle Events interface that will be called when the client gets a LifecycleEvent.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withMaxReconnectDelayMs(Long maxReconnectDelayMs)
Sets the maximum amount of time to wait to reconnect after a disconnect.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withMinConnectedTimeToResetReconnectDelayMs(Long minConnectedTimeToResetReconnectDelayMs)
Sets the minimum time needed to pass to reset the reconnect delay in milliseconds used when the Mqtt5Client connects.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withMinReconnectDelayMs(Long minReconnectDelayMs)
Sets the minimum amount of time to wait to reconnect after a disconnect.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withOfflineQueueBehavior(Mqtt5ClientOptions.ClientOfflineQueueBehavior offlineQueueBehavior)
Sets how disconnects affect the queued and in-progress operations tracked by the client.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withPingTimeoutMs(Long pingTimeoutMs)
Sets the time interval to wait after sending a PINGREQ for a PINGRESP to arrive.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withPort(Long port)
Sets the network port of the MQTT server to connect to.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withPublishEvents(Mqtt5ClientOptions.PublishEvents publishEvents)
Sets the PublishEvents interface that will be called when the client gets a message.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withRetryJitterMode(ExponentialBackoffRetryOptions.JitterMode retryJitterMode)
Sets how the reconnect delay is modified in order to smooth out the distribution of reconnection attempt time points for a large set of reconnecting clients.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withSessionBehavior(Mqtt5ClientOptions.ClientSessionBehavior sessionBehavior)
Sets how the Mqtt5Client should behave with respect to MQTT sessions.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withSocketOptions(SocketOptions socketOptions)
Sets the socket properties of the underlying MQTT connections made by the client.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withTlsContext(TlsContext tlsContext)
Sets the TLS context for secure socket connections.Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withTopicAliasingOptions(TopicAliasingOptions options)
Sets the topic aliasing options for clients constructed from this builderMqtt5ClientOptions.Mqtt5ClientOptionsBuilder
withWebsocketHandshakeTransform(Consumer<Mqtt5WebsocketHandshakeTransformArgs> handshakeTransform)
Sets the callback that allows a custom transformation of the HTTP request that acts as the websocket handshake.
-
-
-
Method Detail
-
withHostName
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withHostName(String hostName)
Sets the host name of the MQTT server to connect to.- Parameters:
hostName
- Host name of the MQTT server to connect to.- Returns:
- The Mqtt5ClientOptionsBuilder after setting the host name
-
withPort
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withPort(Long port)
Sets the network port of the MQTT server to connect to.- Parameters:
port
- Network port of the MQTT server to connect to.- Returns:
- The Mqtt5ClientOptionsBuilder after setting the port
-
withBootstrap
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withBootstrap(ClientBootstrap bootstrap)
Sets the ClientBootstrap to use. In almost all cases, this should be left null.- Parameters:
bootstrap
- The ClientBootstrap to use- Returns:
- The Mqtt5ClientOptionsBuilder after setting the ClientBootstrap
-
withSocketOptions
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withSocketOptions(SocketOptions socketOptions)
Sets the socket properties of the underlying MQTT connections made by the client. Leave null to use defaults (no TCP keep alive, 10 second socket timeout).- Parameters:
socketOptions
- The socket properties of the underlying MQTT connections made by the client.- Returns:
- The Mqtt5ClientOptionsBuilder after setting the socket options
-
withTlsContext
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withTlsContext(TlsContext tlsContext)
Sets the TLS context for secure socket connections. If null, then a plaintext connection will be used.- Parameters:
tlsContext
- The TLS context for secure socket connections.- Returns:
- The Mqtt5ClientOptionsBuilder after setting the TlsContext
-
withHttpProxyOptions
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withHttpProxyOptions(HttpProxyOptions httpProxyOptions)
Sets the (tunneling) HTTP proxy usage when establishing MQTT connection.- Parameters:
httpProxyOptions
- the (tunneling) HTTP proxy usage when establishing MQTT connection.- Returns:
- The Mqtt5ClientOptionsBuilder after setting the HttpProxyOptions
-
withConnectOptions
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withConnectOptions(ConnectPacket connectOptions)
Sets all configurable options with respect to the CONNECT packet sent by the client, including the Will. These connect properties will be used for every connection attempt made by the client.- Parameters:
connectOptions
- Configurable options with respect to the CONNECT packet sent by the client, including the Will.- Returns:
- The Mqtt5ClientOptionsBuilder after setting the connect options
-
withSessionBehavior
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withSessionBehavior(Mqtt5ClientOptions.ClientSessionBehavior sessionBehavior)
Sets how the Mqtt5Client should behave with respect to MQTT sessions.- Parameters:
sessionBehavior
- How the Mqtt5Client should behave with respect to MQTT sessions.- Returns:
- The Mqtt5ClientOptionsBuilder after setting the ClientSessionBehavior
-
withExtendedValidationAndFlowControlOptions
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withExtendedValidationAndFlowControlOptions(Mqtt5ClientOptions.ExtendedValidationAndFlowControlOptions extendedValidationAndFlowControlOptions)
Sets the additional controls for client behavior with respect to operation validation and flow control; these checks go beyond the base MQTT5 spec to respect limits of specific MQTT brokers.- Parameters:
extendedValidationAndFlowControlOptions
- Additional controls for client behavior with respect to operation validation and flow control- Returns:
- The Mqtt5ClientOptionsBuilder after setting the ExtendedValidationAndFlowControlOptions
-
withOfflineQueueBehavior
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withOfflineQueueBehavior(Mqtt5ClientOptions.ClientOfflineQueueBehavior offlineQueueBehavior)
Sets how disconnects affect the queued and in-progress operations tracked by the client. Also controls how new operations are handled while the client is not connected. In particular, if the client is not connected, then any operation that would be failed on disconnect (according to these rules) will also be rejected.- Parameters:
offlineQueueBehavior
- How disconnects affect the queued and in-progress operations tracked by the client- Returns:
- The Mqtt5ClientOptionsBuilder after setting the ClientOfflineQueueBehavior
-
withRetryJitterMode
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withRetryJitterMode(ExponentialBackoffRetryOptions.JitterMode retryJitterMode)
Sets how the reconnect delay is modified in order to smooth out the distribution of reconnection attempt time points for a large set of reconnecting clients.- Parameters:
retryJitterMode
- How the reconnect delay is modified in order to smooth out the distribution of reconnection attempt time points for a large set of reconnecting clients.- Returns:
- The Mqtt5ClientOptionsBuilder after setting the JitterMode
-
withMinReconnectDelayMs
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withMinReconnectDelayMs(Long minReconnectDelayMs)
Sets the minimum amount of time to wait to reconnect after a disconnect. Exponential back-off is performed with jitter after each connection failure.- Parameters:
minReconnectDelayMs
- The minimum amount of time to wait to reconnect after a disconnect.- Returns:
- The Mqtt5ClientOptionsBuilder after setting the minimum reconnect delay
-
withMaxReconnectDelayMs
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withMaxReconnectDelayMs(Long maxReconnectDelayMs)
Sets the maximum amount of time to wait to reconnect after a disconnect. Exponential back-off is performed with jitter after each connection failure.- Parameters:
maxReconnectDelayMs
- The maximum amount of time to wait to reconnect after a disconnect- Returns:
- The Mqtt5ClientOptionsBuilder after setting the maximum reconnect delay
-
withMinConnectedTimeToResetReconnectDelayMs
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withMinConnectedTimeToResetReconnectDelayMs(Long minConnectedTimeToResetReconnectDelayMs)
Sets the minimum time needed to pass to reset the reconnect delay in milliseconds used when the Mqtt5Client connects.- Parameters:
minConnectedTimeToResetReconnectDelayMs
- The minimum time needed to pass to reset the reconnect delay- Returns:
- The Mqtt5ClientOptionsBuilder after setting the minimum time needed to pass to reset the reconnect delay
-
withPingTimeoutMs
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withPingTimeoutMs(Long pingTimeoutMs)
Sets the time interval to wait after sending a PINGREQ for a PINGRESP to arrive. If one does not arrive, the client will close the current connection.- Parameters:
pingTimeoutMs
- The time interval to wait after sending a PINGREQ for a PINGRESP to arrive.- Returns:
- The Mqtt5ClientOptionsBuilder after setting the ping timeout time
-
withConnackTimeoutMs
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withConnackTimeoutMs(Long connackTimeoutMs)
Sets the time interval to wait after sending a CONNECT request for a CONNACK to arrive. If one does not arrive, the connection will be shut down.- Parameters:
connackTimeoutMs
- The time interval to wait after sending a CONNECT request for a CONNACK to arrive.- Returns:
- The Mqtt5ClientOptionsBuilder after setting the timeout in milliseconds for getting a ConnAckPacket from the server
-
withAckTimeoutSeconds
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withAckTimeoutSeconds(Long ackTimeoutSeconds)
Sets the time interval to wait for an ack after sending a QoS 1+ PUBLISH, SUBSCRIBE, or UNSUBSCRIBE before failing the operation.- Parameters:
ackTimeoutSeconds
- The time interval to wait for an ack after sending a QoS 1+ PUBLISH, SUBSCRIBE, or UNSUBSCRIBE before failing the operation.- Returns:
- The Mqtt5ClientOptionsBuilder after setting the timeout in milliseconds for getting an ACK packet from the server when performing an operation
-
withLifecycleEvents
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withLifecycleEvents(Mqtt5ClientOptions.LifecycleEvents lifecycleEvents)
Sets the Lifecycle Events interface that will be called when the client gets a LifecycleEvent.- Parameters:
lifecycleEvents
- The LifecycleEvents interface that will be called- Returns:
- The Mqtt5ClientOptionsBuilder after setting the Lifecycle Events interface
-
withWebsocketHandshakeTransform
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withWebsocketHandshakeTransform(Consumer<Mqtt5WebsocketHandshakeTransformArgs> handshakeTransform)
Sets the callback that allows a custom transformation of the HTTP request that acts as the websocket handshake. Websockets will be used if this is set to a valid transformation callback. To use websockets but not perform a transformation, just set this as a trivial completion callback. If null, the connection will be made with direct MQTT.- Parameters:
handshakeTransform
- Callback that allows a custom transformation of the HTTP request that acts as the websocket handshake.- Returns:
- The Mqtt5ClientOptionsBuilder after setting the websocket handshake transform callback
-
withPublishEvents
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withPublishEvents(Mqtt5ClientOptions.PublishEvents publishEvents)
Sets the PublishEvents interface that will be called when the client gets a message.- Parameters:
publishEvents
- The PublishEvents interface that will be called when the client gets a message.- Returns:
- The Mqtt5ClientOptionsBuilder after setting the PublishEvents interface
-
withTopicAliasingOptions
public Mqtt5ClientOptions.Mqtt5ClientOptionsBuilder withTopicAliasingOptions(TopicAliasingOptions options)
Sets the topic aliasing options for clients constructed from this builder- Parameters:
options
- topic aliasing options that the client should use- Returns:
- The Mqtt5ClientOptionsBuilder object
-
build
public Mqtt5ClientOptions build()
Returns a Mqtt5ClientOptions class configured with all of the options set in the Mqtt5ClientOptionsBuilder. This can then be used to make a new Mqtt5Client.- Returns:
- A configured Mqtt5ClientOptions
-
-