@DoNotImplement public interface Mqtt5ClientReconnector extends MqttClientReconnector
MqttClientReconnector
with methods specific to an Mqtt5Client
.DEFAULT_DELAY_MS, DEFAULT_RECONNECT, DEFAULT_REPUBLISH_IF_SESSION_EXPIRED, DEFAULT_RESUBSCRIBE_IF_SESSION_EXPIRED
Modifier and Type | Method and Description |
---|---|
@NotNull Mqtt5ClientReconnector |
connect(@NotNull Mqtt5Connect connect)
Sets a different Connect message the client will try to reconnect with.
|
Mqtt5ConnectBuilder.Nested<? extends Mqtt5ClientReconnector> |
connectWith()
Fluent counterpart of
connect(Mqtt5Connect) . |
@NotNull Mqtt5ClientReconnector |
delay(long delay,
@NotNull TimeUnit timeUnit)
Sets a delay the client will wait for before trying to reconnect.
|
@NotNull Mqtt5Connect |
getConnect()
Returns the currently set Connect message the client will try to reconnect with.
|
@NotNull Mqtt5ClientReconnector |
reconnect(boolean reconnect)
Instructs the client to reconnect or not.
|
<T> @NotNull Mqtt5ClientReconnector |
reconnectWhen(@NotNull CompletableFuture<T> future,
@Nullable BiConsumer<? super T,? super Throwable> callback)
Instructs the client to reconnect after a future completes.
|
@NotNull Mqtt5ClientReconnector |
republishIfSessionExpired(boolean republish)
Instructs the client to queue pending Publish messages and automatically publish them even if the session expired
before reconnected successfully.
|
@NotNull Mqtt5ClientReconnector |
resubscribeIfSessionExpired(boolean resubscribe)
Instructs the client to automatically restore its subscriptions when the session expired before it reconnected
successfully.
|
MqttClientTransportConfigBuilder.Nested<? extends Mqtt5ClientReconnector> |
transportConfig()
Fluent counterpart of
MqttClientReconnector.transportConfig(MqttClientTransportConfig) . |
@NotNull Mqtt5ClientReconnector |
transportConfig(@NotNull MqttClientTransportConfig transportConfig)
Sets a different transport configuration the client will try to reconnect with.
|
getAttempts, getDelay, getTransportConfig, isReconnect, isRepublishIfSessionExpired, isResubscribeIfSessionExpired
@NotNull @NotNull Mqtt5ClientReconnector reconnect(boolean reconnect)
MqttClientReconnector
reconnect
in interface MqttClientReconnector
reconnect
- whether to reconnect.@NotNull <T> @NotNull Mqtt5ClientReconnector reconnectWhen(@NotNull @NotNull CompletableFuture<T> future, @Nullable @Nullable BiConsumer<? super T,? super Throwable> callback)
MqttClientReconnector
If additionally a delay
is supplied, the client will reconnect after both are
complete.
This method must only be called in MqttClientDisconnectedListener.onDisconnected(MqttClientDisconnectedContext)
and not in the supplied callback.
reconnectWhen
in interface MqttClientReconnector
T
- the result type of the future.future
- the client will reconnect only after the future completes.callback
- the callback that will be called after the future completes and before the client will reconnect.
It can be used to set new connect properties (e.g. credentials).@NotNull @NotNull Mqtt5ClientReconnector resubscribeIfSessionExpired(boolean resubscribe)
MqttClientReconnector
When the client reconnected successfully and its session is still present, the server still knows its subscriptions and they do not need to be restored.
This setting only has effect if the client will reconnect (at least one of the methods MqttClientReconnector.reconnect(boolean)
or MqttClientReconnector.reconnectWhen(CompletableFuture, BiConsumer)
is called).
This method must only be called in MqttClientDisconnectedListener.onDisconnected(MqttClientDisconnectedContext)
and not in the callback supplied to MqttClientReconnector.reconnectWhen(CompletableFuture, BiConsumer)
.
resubscribeIfSessionExpired
in interface MqttClientReconnector
resubscribe
- whether to resubscribe when the session expired before the client reconnected successfully.@NotNull @NotNull Mqtt5ClientReconnector republishIfSessionExpired(boolean republish)
MqttClientReconnector
When the client reconnected successfully and its session is still present, the client will always queue pending Publish messages and automatically publish them to ensure the QoS guarantees.
This setting only has effect if the client will reconnect (at least one of the methods MqttClientReconnector.reconnect(boolean)
or MqttClientReconnector.reconnectWhen(CompletableFuture, BiConsumer)
is called).
This method must only be called in MqttClientDisconnectedListener.onDisconnected(MqttClientDisconnectedContext)
and not in the callback supplied to MqttClientReconnector.reconnectWhen(CompletableFuture, BiConsumer)
.
republishIfSessionExpired
in interface MqttClientReconnector
republish
- whether to republish when the session expired before the client reconnected successfully.@NotNull @NotNull Mqtt5ClientReconnector delay(long delay, @NotNull @NotNull TimeUnit timeUnit)
MqttClientReconnector
This setting only has effect if the client will reconnect (at least one of the methods MqttClientReconnector.reconnect(boolean)
or MqttClientReconnector.reconnectWhen(CompletableFuture, BiConsumer)
is called).
If additionally a future
is supplied, the client will
reconnect after both are complete.
This method must only be called in MqttClientDisconnectedListener.onDisconnected(MqttClientDisconnectedContext)
and not in the callback supplied to MqttClientReconnector.reconnectWhen(CompletableFuture, BiConsumer)
.
delay
in interface MqttClientReconnector
delay
- delay which the client will wait before trying to reconnect.timeUnit
- the time unit of the delay.@NotNull @NotNull Mqtt5ClientReconnector transportConfig(@NotNull @NotNull MqttClientTransportConfig transportConfig)
MqttClientReconnector
transportConfig
in interface MqttClientReconnector
transportConfig
- the transport configuration the client will try to reconnect with.@CheckReturnValue MqttClientTransportConfigBuilder.Nested<? extends Mqtt5ClientReconnector> transportConfig()
MqttClientReconnector
MqttClientReconnector.transportConfig(MqttClientTransportConfig)
.
Calling MqttClientTransportConfigBuilder.Nested#applyTransportConfig()
on the returned builder has the
effect of extending the current transport configuration.
transportConfig
in interface MqttClientReconnector
MqttClientReconnector.transportConfig(MqttClientTransportConfig)
@NotNull @NotNull Mqtt5ClientReconnector connect(@NotNull @NotNull Mqtt5Connect connect)
connect
- the Connect message.@CheckReturnValue Mqtt5ConnectBuilder.Nested<? extends Mqtt5ClientReconnector> connectWith()
connect(Mqtt5Connect)
.
Calling Mqtt5ConnectBuilder.Nested#applyConnect()
on the returned builder has the same effect as calling
connect(Mqtt5Connect)
with the result of Mqtt5ConnectBuilder.build()
.
connect(Mqtt5Connect)
@NotNull @NotNull Mqtt5Connect getConnect()
If the connect(Mqtt5Connect)
method has not been called before (including previous MqttClientDisconnectedListeners
) it will be the
Connect message that is reconstructed from the Mqtt5ClientConnectionConfig
or the Connect message of the previous connect try if it has not been successfully
connected.