Package com.hivemq.client.mqtt.lifecycle
Interface MqttClientAutoReconnect
- All Superinterfaces:
MqttClientDisconnectedListener
Automatic reconnect strategy using an exponential backoff with configurable initial and maximum delays.
The initial delay will be doubled for every unsuccessful connect attempt. The actual delay will be capped at the maximum delay. Additionally a random delay of +-25% will be added.
- Since:
- 1.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe default maximum delay in seconds the client will wait before it tries to reconnect.static final longThe default initial delay in seconds the client will wait before it tries to reconnect. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a builder for an automatic reconnect strategy.extend()Creates a builder for extending this automatic reconnect strategy.longgetInitialDelay(@NotNull TimeUnit timeUnit) Returns the initial delay the client will wait before it tries to reconnect.longgetMaxDelay(@NotNull TimeUnit timeUnit) Returns the maximum delay the client will wait before it tries to reconnect.Methods inherited from interface com.hivemq.client.mqtt.lifecycle.MqttClientDisconnectedListener
onDisconnected
-
Field Details
-
DEFAULT_START_DELAY_S
static final long DEFAULT_START_DELAY_SThe default initial delay in seconds the client will wait before it tries to reconnect.- See Also:
-
DEFAULT_MAX_DELAY_S
static final long DEFAULT_MAX_DELAY_SThe default maximum delay in seconds the client will wait before it tries to reconnect.- See Also:
-
-
Method Details
-
builder
Creates a builder for an automatic reconnect strategy.- Returns:
- the created builder for an automatic reconnect strategy.
-
getInitialDelay
Returns the initial delay the client will wait before it tries to reconnect.This delay will be doubled for every unsuccessful connect attempt.
- Parameters:
timeUnit- the time unit of the returned initial delay.- Returns:
- the start delay in the given time unit.
-
getMaxDelay
Returns the maximum delay the client will wait before it tries to reconnect.- Parameters:
timeUnit- the time unit of the returned maximum delay.- Returns:
- the maximum delay in the given time unit.
-
extend
Creates a builder for extending this automatic reconnect strategy.- Returns:
- the created builder.
-