Class RetryOptions.Builder
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build RetryOptions without performing validation as validation should be done after merging withMethodRetry.setBackoffCoefficient(double backoffCoefficient) Coefficient used to calculate the next retry interval.setDoNotRetry(String... doNotRetry) List of application failures types to not retry.setInitialInterval(Duration initialInterval) Interval of the first retry.setMaximumAttempts(int maximumAttempts) When exceeded the amount of attempts, stop.setMaximumInterval(Duration maximumInterval) Maximum interval between retries.Validates property values and builds RetryOptions with default values.
-
Method Details
-
setInitialInterval
Interval of the first retry. If coefficient is 1.0 then it is used for all retries. Required. -
setBackoffCoefficient
Coefficient used to calculate the next retry interval. The next retry interval is previous interval multiplied by this coefficient. Must be 1 or larger. Default is 2.0.- Throws:
IllegalArgumentException- ifbackoffCoefficientis less than 1.0
-
setMaximumAttempts
When exceeded the amount of attempts, stop. Even if expiration time is not reached.
Default is unlimited.- Parameters:
maximumAttempts- Maximum number of attempts. Default will be used if set to0.- Throws:
IllegalArgumentException- ifmaximumAttemptsis less than 0
-
setMaximumInterval
Maximum interval between retries. Exponential backoff leads to interval increase. This value is the cap of the increase.
Default is 100x of initial interval. Can't be less thansetInitialInterval(Duration)- Parameters:
maximumInterval- the maximum interval value. Default will be used if set tonull.- Throws:
IllegalArgumentException- ifmaximumIntervalis not null and not positive
-
setDoNotRetry
List of application failures types to not retry.An application failure is represented as
ApplicationFailure. The type of the failure is stored in theApplicationFailure.getType()property. AnApplicationFailureinstance is created throughApplicationFailure.newFailure(String, String, Object...). An ApplicationFailure created throughApplicationFailure.newNonRetryableFailure(String, String, Object...)will haveApplicationFailure.isNonRetryable()property set to true which means that it is not retried even if the type of failure is not included into DoNotRetry list.If an activity or workflow throws any exception which is not
ApplicationFailurethen the exception is converted toApplicationFailurewith the fully qualified name of the exception as type value.Note that activity failures are wrapped into
ActivityFailureexception. So if an activity failure is not handled the workflow retry policy is going to see ActivityFailure which is always retryable, not the original exception. The same way a child workflow failure is wrapped intoChildWorkflowFailure.ErrorandCanceledFailureare never retried and are not even passed to this filter. -
build
Build RetryOptions without performing validation as validation should be done after merging withMethodRetry. -
validateBuildWithDefaults
Validates property values and builds RetryOptions with default values.
-