Interface MqttClientAutoReconnect

All Superinterfaces:
MqttClientDisconnectedListener

@DoNotImplement public interface MqttClientAutoReconnect extends 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

    Fields
    Modifier and Type
    Field
    Description
    static final long
    The default maximum delay in seconds the client will wait before it tries to reconnect.
    static final long
    The default initial delay in seconds the client will wait before it tries to reconnect.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a builder for an automatic reconnect strategy.
    Creates a builder for extending this automatic reconnect strategy.
    long
    getInitialDelay(@NotNull TimeUnit timeUnit)
    Returns the initial delay the client will wait before it tries to reconnect.
    long
    getMaxDelay(@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_S
      The 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_S
      The default maximum delay in seconds the client will wait before it tries to reconnect.
      See Also:
  • Method Details

    • builder

      @NotNull static @NotNull MqttClientAutoReconnectBuilder builder()
      Creates a builder for an automatic reconnect strategy.
      Returns:
      the created builder for an automatic reconnect strategy.
    • getInitialDelay

      long getInitialDelay(@NotNull @NotNull TimeUnit timeUnit)
      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

      long getMaxDelay(@NotNull @NotNull TimeUnit timeUnit)
      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

      @NotNull @NotNull MqttClientAutoReconnectBuilder extend()
      Creates a builder for extending this automatic reconnect strategy.
      Returns:
      the created builder.