@DoNotImplement public interface Mqtt3ClientReconnector extends MqttClientReconnector
MqttClientReconnector
with methods specific to an Mqtt3Client
.DEFAULT_DELAY_MS, DEFAULT_RECONNECT, DEFAULT_REPUBLISH_IF_SESSION_EXPIRED, DEFAULT_RESUBSCRIBE_IF_SESSION_EXPIRED
Modifier and Type | Method and Description |
---|---|
@NotNull Mqtt3ClientReconnector |
connect(@NotNull Mqtt3Connect connect)
Sets a different Connect message the client will try to reconnect with.
|
Mqtt3ConnectBuilder.Nested<? extends Mqtt3ClientReconnector> |
connectWith()
Fluent counterpart of
connect(Mqtt3Connect) . |
@NotNull Mqtt3ClientReconnector |
delay(long delay,
@NotNull TimeUnit timeUnit)
Sets a delay the client will wait for before trying to reconnect.
|
@NotNull Mqtt3Connect |
getConnect()
Returns the currently set Connect message the client will try to reconnect with.
|
@NotNull Mqtt3ClientReconnector |
reconnect(boolean reconnect)
Instructs the client to reconnect or not.
|
<T> @NotNull Mqtt3ClientReconnector |
reconnectWhen(@NotNull CompletableFuture<T> future,
@Nullable BiConsumer<? super T,? super Throwable> callback)
Instructs the client to reconnect after a future completes.
|
@NotNull Mqtt3ClientReconnector |
republishIfSessionExpired(boolean republish)
Instructs the client to queue pending Publish messages and automatically publish them even if the session expired
before reconnected successfully.
|
@NotNull Mqtt3ClientReconnector |
resubscribeIfSessionExpired(boolean resubscribe)
Instructs the client to automatically restore its subscriptions when the session expired before it reconnected
successfully.
|
MqttClientTransportConfigBuilder.Nested<? extends Mqtt3ClientReconnector> |
transportConfig()
Fluent counterpart of
MqttClientReconnector.transportConfig(MqttClientTransportConfig) . |
@NotNull Mqtt3ClientReconnector |
transportConfig(@NotNull MqttClientTransportConfig transportConfig)
Sets a different transport configuration the client will try to reconnect with.
|
getAttempts, getDelay, getTransportConfig, isReconnect, isRepublishIfSessionExpired, isResubscribeIfSessionExpired
@NotNull @NotNull Mqtt3ClientReconnector reconnect(boolean reconnect)
MqttClientReconnector
reconnect
in interface MqttClientReconnector
reconnect
- whether to reconnect.@NotNull <T> @NotNull Mqtt3ClientReconnector 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 Mqtt3ClientReconnector 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 Mqtt3ClientReconnector 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 Mqtt3ClientReconnector 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 Mqtt3ClientReconnector 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 Mqtt3ClientReconnector> 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 Mqtt3ClientReconnector connect(@NotNull @NotNull Mqtt3Connect connect)
connect
- the Connect message.@CheckReturnValue Mqtt3ConnectBuilder.Nested<? extends Mqtt3ClientReconnector> connectWith()
connect(Mqtt3Connect)
.
Calling Mqtt3ConnectBuilder.Nested#applyConnect()
on the returned builder has the same effect as calling
connect(Mqtt3Connect)
with the result of Mqtt3ConnectBuilder.build()
.
connect(Mqtt3Connect)
@NotNull @NotNull Mqtt3Connect getConnect()
If the connect(Mqtt3Connect)
method has not been called before (including previous MqttClientDisconnectedListeners
) it will be the
Connect message that is reconstructed from the Mqtt3ClientConnectionConfig
or the Connect message of the previous connect try if it has not been successfully
connected.