Package com.helger.phase4.messaging.http
Class HttpRetrySettings
java.lang.Object
com.helger.phase4.messaging.http.HttpRetrySettings
An object encapsulating the HTTP retry settings. By default retries are
disabled.
- Since:
- 0.13.0
- Author:
- Philip Helger
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidassignFrom(HttpRetrySettings aOther) booleanfinal Durationstatic DurationgetIncreased(Duration aDuration, BigDecimal aRetryIncreaseFactor) final intfinal BigDecimalinthashCode()booleanfinal HttpRetrySettingssetDurationBeforeRetry(Duration aDurationBeforeRetry) Set the duration before the first retry.final HttpRetrySettingssetMaxRetries(int nMaxRetries) Set the maximum number of retries.final HttpRetrySettingssetRetryIncreaseFactor(BigDecimal aRetryIncreaseFactor) Set the retry increase factor to use. 1 means no increase. 2 means the waiting time doubles every time.toString()
-
Field Details
-
DEFAULT_MAX_RETRIES
public static final int DEFAULT_MAX_RETRIES- See Also:
-
DEFAULT_RETRY_DURATION
-
DEFAULT_RETRY_INCREASE_FACTOR
-
-
Constructor Details
-
HttpRetrySettings
public HttpRetrySettings()
-
-
Method Details
-
isRetryEnabled
public boolean isRetryEnabled()- Returns:
trueif retries are enabled,falseif not. Only iftrueis returned further calls togetMaxRetries(),getDurationBeforeRetry()andgetRetryIncreaseFactor()make sense.
-
getMaxRetries
public final int getMaxRetries()- Returns:
- The maximum number of retries. Only if this value is > 0, retries are enabled.
- See Also:
-
setMaxRetries
Set the maximum number of retries.- Parameters:
nMaxRetries- New maximum. Any value ≤ 0 means "no retries".- Returns:
- this for chaining
-
getDurationBeforeRetry
- Returns:
- The duration before the first retry. Never
null. The caller needs to ensure to increase the duration with the factor provided fromgetRetryIncreaseFactor(). ThegetIncreased(Duration, BigDecimal)utility method may be used to perform the necessary increase. - See Also:
-
setDurationBeforeRetry
@Nonnull public final HttpRetrySettings setDurationBeforeRetry(@Nonnull Duration aDurationBeforeRetry) Set the duration before the first retry.- Parameters:
aDurationBeforeRetry- The duration to use. May not benull.- Returns:
- this for chaining
-
getRetryIncreaseFactor
- Returns:
- The retry increase factory, that should be applied for every retry
after the first one. Never
null. An increase factor of 1 means no increase. An increase factor of 2 means the waiting time doubles. The default is 1. Return values are always > 0.
-
setRetryIncreaseFactor
@Nonnull public final HttpRetrySettings setRetryIncreaseFactor(@Nonnull BigDecimal aRetryIncreaseFactor) Set the retry increase factor to use. 1 means no increase. 2 means the waiting time doubles every time. Only value > 0 are allowed.- Parameters:
aRetryIncreaseFactor- The retry increase factor. May not benulland must be > 0.- Returns:
- this for chaining
-
getIncreased
-
assignFrom
-
equals
-
hashCode
public int hashCode() -
toString
-