Class RetryContextManager


  • @SnowflakeJdbcInternalApi
    public class RetryContextManager
    extends Object
    RetryContextManager lets you register logic (as callbacks) that will be re-executed during a retry of a request.
    • Constructor Detail

      • RetryContextManager

        public RetryContextManager()
        Default constructor using ALWAYS_BEFORE_RETRY as the default retry hook.
      • RetryContextManager

        public RetryContextManager​(RetryContextManager.RetryHook retryHook)
        Constructor that accepts a specific RetryHook.
        Parameters:
        retryHook - the retry hook strategy.
    • Method Detail

      • registerRetryCallback

        public RetryContextManager registerRetryCallback​(ThrowingBiFunction<org.apache.http.client.methods.HttpRequestBase,​RetryContext,​RetryContext,​SnowflakeSQLException> callback)
        Registers a retry callback that will be executed on each retry.
        Parameters:
        callback - A RetryCallback encapsulating the logic to be replayed on retry.
        Returns:
        the current instance for fluent chaining.
      • executeRetryCallbacks

        public void executeRetryCallbacks​(org.apache.http.client.methods.HttpRequestBase requestToRetry)
                                   throws SnowflakeSQLException
        Executes all registered retry callbacks in the order they were added, before reattempting the operation.
        Parameters:
        requestToRetry - the HTTP request to retry.
        Throws:
        SnowflakeSQLException - if an error occurs during callback execution.