Interface Mqtt5ClientReconnector
- All Superinterfaces:
MqttClientReconnector
MqttClientReconnector with methods specific to an Mqtt5Client.- Since:
- 1.1
-
Field Summary
Fields inherited from interface com.hivemq.client.mqtt.lifecycle.MqttClientReconnector
DEFAULT_DELAY_MS, DEFAULT_RECONNECT, DEFAULT_REPUBLISH_IF_SESSION_EXPIRED, DEFAULT_RESUBSCRIBE_IF_SESSION_EXPIRED, DEFAULT_RESUBSCRIBE_IF_SESSION_PRESENT -
Method Summary
Modifier and TypeMethodDescriptionconnect(@NotNull Mqtt5Connect connect) Sets a different Connect message the client will try to reconnect with.Fluent counterpart ofconnect(Mqtt5Connect).Sets a delay the client will wait for before trying to reconnect.Returns the currently set Connect message the client will try to reconnect with.reconnect(boolean reconnect) Instructs the client to reconnect or not.reconnectWhen(@NotNull CompletableFuture<T> future, @Nullable BiConsumer<? super T, ? super Throwable> callback) Instructs the client to reconnect after a future completes.republishIfSessionExpired(boolean republish) Instructs the client to queue pending Publish messages and automatically publish them even if the session expired before reconnected successfully.resubscribeIfSessionExpired(boolean resubscribe) Instructs the client to automatically restore its subscriptions when the session expired before it reconnected successfully.resubscribeIfSessionPresent(boolean resubscribeIfSessionPresent) Instructs the client to automatically restore its subscriptions when reconnected successfully and the session is still present.Fluent counterpart ofMqttClientReconnector.transportConfig(MqttClientTransportConfig).transportConfig(@NotNull MqttClientTransportConfig transportConfig) Sets a different transport configuration the client will try to reconnect with.Methods inherited from interface com.hivemq.client.mqtt.lifecycle.MqttClientReconnector
getAttempts, getDelay, getTransportConfig, isReconnect, isRepublishIfSessionExpired, isResubscribeIfSessionExpired, isResubscribeIfSessionPresent
-
Method Details
-
reconnect
Description copied from interface:MqttClientReconnectorInstructs the client to reconnect or not.- Specified by:
reconnectin interfaceMqttClientReconnector- Parameters:
reconnect- whether to reconnect.- Returns:
- this reconnector.
-
reconnectWhen
@NotNull <T> @NotNull Mqtt5ClientReconnector reconnectWhen(@NotNull @NotNull CompletableFuture<T> future, @Nullable @Nullable BiConsumer<? super T, ? super Throwable> callback) Description copied from interface:MqttClientReconnectorInstructs the client to reconnect after a future completes.If additionally a
delayis 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.- Specified by:
reconnectWhenin interfaceMqttClientReconnector- Type Parameters:
T- the result type of the future.- Parameters:
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).- Returns:
- this reconnector.
-
resubscribeIfSessionPresent
@NotNull @NotNull Mqtt5ClientReconnector resubscribeIfSessionPresent(boolean resubscribeIfSessionPresent) Description copied from interface:MqttClientReconnectorInstructs the client to automatically restore its subscriptions when reconnected successfully and the session is still present.When the client reconnected successfully and its session is still present, the server still knows its subscriptions, so resubscribing is optional.
This setting only has effect if the client will reconnect (at least one of the methods
MqttClientReconnector.reconnect(boolean)orMqttClientReconnector.reconnectWhen(CompletableFuture, BiConsumer)is called).This method must only be called in
MqttClientDisconnectedListener.onDisconnected(MqttClientDisconnectedContext)and not in the callback supplied toMqttClientReconnector.reconnectWhen(CompletableFuture, BiConsumer).- Specified by:
resubscribeIfSessionPresentin interfaceMqttClientReconnector- Parameters:
resubscribeIfSessionPresent- whether to resubscribe if the session is present when the client reconnected successfully.- Returns:
- this reconnector.
-
resubscribeIfSessionExpired
Description copied from interface:MqttClientReconnectorInstructs the client to automatically restore its subscriptions when the session expired before it reconnected successfully.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)orMqttClientReconnector.reconnectWhen(CompletableFuture, BiConsumer)is called).This method must only be called in
MqttClientDisconnectedListener.onDisconnected(MqttClientDisconnectedContext)and not in the callback supplied toMqttClientReconnector.reconnectWhen(CompletableFuture, BiConsumer).- Specified by:
resubscribeIfSessionExpiredin interfaceMqttClientReconnector- Parameters:
resubscribe- whether to resubscribe when the session expired before the client reconnected successfully.- Returns:
- this reconnector.
-
republishIfSessionExpired
Description copied from interface:MqttClientReconnectorInstructs the client to queue pending Publish messages and automatically publish them even if the session expired before reconnected successfully.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)orMqttClientReconnector.reconnectWhen(CompletableFuture, BiConsumer)is called).This method must only be called in
MqttClientDisconnectedListener.onDisconnected(MqttClientDisconnectedContext)and not in the callback supplied toMqttClientReconnector.reconnectWhen(CompletableFuture, BiConsumer).- Specified by:
republishIfSessionExpiredin interfaceMqttClientReconnector- Parameters:
republish- whether to republish when the session expired before the client reconnected successfully.- Returns:
- this reconnector.
-
delay
Description copied from interface:MqttClientReconnectorSets a delay the client will wait for before trying to reconnect.This setting only has effect if the client will reconnect (at least one of the methods
MqttClientReconnector.reconnect(boolean)orMqttClientReconnector.reconnectWhen(CompletableFuture, BiConsumer)is called).If additionally a
futureis 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 toMqttClientReconnector.reconnectWhen(CompletableFuture, BiConsumer).- Specified by:
delayin interfaceMqttClientReconnector- Parameters:
delay- delay which the client will wait before trying to reconnect.timeUnit- the time unit of the delay.- Returns:
- this reconnector.
-
transportConfig
@NotNull @NotNull Mqtt5ClientReconnector transportConfig(@NotNull @NotNull MqttClientTransportConfig transportConfig) Description copied from interface:MqttClientReconnectorSets a different transport configuration the client will try to reconnect with.- Specified by:
transportConfigin interfaceMqttClientReconnector- Parameters:
transportConfig- the transport configuration the client will try to reconnect with.- Returns:
- this reconnector.
-
transportConfig
@CheckReturnValue @NotNull MqttClientTransportConfigBuilder.Nested<? extends Mqtt5ClientReconnector> transportConfig()Description copied from interface:MqttClientReconnectorFluent counterpart ofMqttClientReconnector.transportConfig(MqttClientTransportConfig).Calling
MqttClientTransportConfigBuilder.Nested.applyTransportConfig()on the returned builder has the effect of extending the current transport configuration.- Specified by:
transportConfigin interfaceMqttClientReconnector- Returns:
- the fluent builder for the transport configuration.
- See Also:
-
connect
Sets a different Connect message the client will try to reconnect with.- Parameters:
connect- the Connect message.- Returns:
- this reconnector.
-
connectWith
@CheckReturnValue @NotNull Mqtt5ConnectBuilder.Nested<? extends Mqtt5ClientReconnector> connectWith()Fluent counterpart ofconnect(Mqtt5Connect).Calling
Mqtt5ConnectBuilder.Nested.applyConnect()on the returned builder has the same effect as callingconnect(Mqtt5Connect)with the result ofMqtt5ConnectBuilder.build().- Returns:
- the fluent builder for the Connect message.
- See Also:
-
getConnect
Returns the currently set Connect message the client will try to reconnect with.If the
connect(Mqtt5Connect)method has not been called before (including previousMqttClientDisconnectedListeners) it will be the Connect message that is reconstructed from theMqtt5ClientConnectionConfigor the Connect message of the previous connect try if it has not been successfully connected.- Returns:
- the Connect message.
-