GracefulReconnect
Keywords: net.corda.client.rpc.GracefulReconnect class
Date: 2023-09-18

net.corda.client.rpc

## Class GracefulReconnect

- net.corda.client.rpc.GracefulReconnect

-     public class GracefulReconnect

  GracefulReconnect provides the opportunity to perform certain logic when the RPC encounters a connection disconnect during communication with the node.

  NOTE: The callbacks provided may be executed on a separate thread to that which called the RPC command.

- - ### Constructor Detail

    - #### GracefulReconnect

          public GracefulReconnect(@NotNull
                                   kotlin.jvm.functions.Function0<kotlin.Unit> onDisconnect,
                                   @NotNull
                                   kotlin.jvm.functions.Function0<kotlin.Unit> onReconnect,
                                   int maxAttempts)

      GracefulReconnect provides the opportunity to perform certain logic when the RPC encounters a connection disconnect during communication with the node.

      NOTE: The callbacks provided may be executed on a separate thread to that which called the RPC command.

      Parameters:
        `onDisconnect` - implement this callback to perform logic when the RPC disconnects on connection disconnect
        `onReconnect` - implement this callback to perform logic when the RPC has reconnected after connection disconnect
        `maxAttempts` - the maximum number of attempts per each individual RPC call. A negative number indicates infinite number of retries. The default value is 5.

    - #### GracefulReconnect

          public GracefulReconnect()

      GracefulReconnect provides the opportunity to perform certain logic when the RPC encounters a connection disconnect during communication with the node.

      NOTE: The callbacks provided may be executed on a separate thread to that which called the RPC command.

    - #### GracefulReconnect

          @JvmOverloads
          public GracefulReconnect(@NotNull
                                                 java.lang.Runnable onDisconnect,
                                                 @NotNull
                                                 java.lang.Runnable onReconnect,
                                                 int maxAttempts)

    - #### GracefulReconnect

          @JvmOverloads
          public GracefulReconnect(@NotNull
                                                 java.lang.Runnable onDisconnect,
                                                 @NotNull
                                                 java.lang.Runnable onReconnect)

  - ### Method Detail

    - #### getOnDisconnect

          @NotNull
          public kotlin.jvm.functions.Function0<kotlin.Unit> getOnDisconnect()

      implement this callback to perform logic when the RPC disconnects on connection disconnect

    - #### getOnReconnect

          @NotNull
          public kotlin.jvm.functions.Function0<kotlin.Unit> getOnReconnect()

      implement this callback to perform logic when the RPC has reconnected after connection disconnect

    - #### getMaxAttempts

          public int getMaxAttempts()

      the maximum number of attempts per each individual RPC call.

      A negative number indicates infinite number of retries. The default value is 5.