RetryStrategy Class

  • java.lang.Object
    • com.microsoft.bot.restclient.retry.RetryStrategy

public abstract class RetryStrategy

Represents a retry strategy that determines the number of retry attempts and the interval between retries.

Field Summary

Modifier and Type Field and Description
static final int DEFAULT_CLIENT_RETRY_COUNT

Represents the default number of retry attempts.

static final boolean DEFAULT_FIRST_FAST_RETRY

Represents the default flag indicating whether the first retry attempt will be made immediately, whereas subsequent retries will remain subject to the retry interval.

static final int DEFAULT_RETRY_INTERVAL

Represents the default interval between retries.

Constructor Summary

Modifier Constructor Description
protected RetryStrategy(String name, boolean firstFastRetry)

Initializes a new instance of the RetryStrategy class.

Method Summary

Modifier and Type Method and Description
boolean isFastFirstRetry()

Gets whether the first retry attempt will be made immediately.

java.lang.String name()

Gets the name of the retry strategy.

abstract boolean shouldRetry(int retryCount, Response response)

Returns if a request should be retried based on the retry count, current response, and the current strategy.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Field Details

DEFAULT_CLIENT_RETRY_COUNT

public static final int DEFAULT_CLIENT_RETRY_COUNT

Represents the default number of retry attempts.

DEFAULT_FIRST_FAST_RETRY

public static final boolean DEFAULT_FIRST_FAST_RETRY

Represents the default flag indicating whether the first retry attempt will be made immediately, whereas subsequent retries will remain subject to the retry interval.

DEFAULT_RETRY_INTERVAL

public static final int DEFAULT_RETRY_INTERVAL

Represents the default interval between retries.

Constructor Details

RetryStrategy

protected RetryStrategy(String name, boolean firstFastRetry)

Initializes a new instance of the RetryStrategy class.

Parameters:

name - The name of the retry strategy.
firstFastRetry - true to immediately retry in the first attempt; otherwise, false.

Method Details

isFastFirstRetry

public boolean isFastFirstRetry()

Gets whether the first retry attempt will be made immediately.

Returns:

true if the first retry attempt will be made immediately. false otherwise.

name

public String name()

Gets the name of the retry strategy.

Returns:

the name of the retry strategy.

shouldRetry

public abstract boolean shouldRetry(int retryCount, Response response)

Returns if a request should be retried based on the retry count, current response, and the current strategy.

Parameters:

retryCount - The current retry attempt count.
response - The exception that caused the retry conditions to occur.

Returns:

true if the request should be retried; false otherwise.

Applies to