Class RetryOptions.Builder

  • Enclosing class:
    RetryOptions

    public static final class RetryOptions.Builder
    extends java.lang.Object
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • setInitialInterval

        public RetryOptions.Builder setInitialInterval​(java.time.Duration initialInterval)
        Interval of the first retry. If coefficient is 1.0 then it is used for all retries. Required.
      • setExpiration

        public RetryOptions.Builder setExpiration​(java.time.Duration expiration)
        Maximum time to retry. Required. When exceeded the retries stop even if maximum retries is not reached yet.
      • setBackoffCoefficient

        public RetryOptions.Builder setBackoffCoefficient​(double backoffCoefficient)
        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.
      • setMaximumAttempts

        public RetryOptions.Builder setMaximumAttempts​(int maximumAttempts)
        Maximum number of attempts. When exceeded the retries stop even if not expired yet. Must be 1 or bigger. Default is unlimited.
      • setMaximumInterval

        public RetryOptions.Builder setMaximumInterval​(java.time.Duration maximumInterval)
        Maximum interval between retries. Exponential backoff leads to interval increase. This value is the cap of the increase. Default is 100x of initial interval.
      • setDoNotRetry

        @SafeVarargs
        public final RetryOptions.Builder setDoNotRetry​(java.lang.Class<? extends java.lang.Throwable>... doNotRetry)
        List of exceptions to skip retry. When matching an exact match is used. So adding RuntimeException.class to this list is going to include only RuntimeException itself, not all of its subclasses. The reason for such behaviour is to be able to support server side retries without knowledge of Java exception hierarchy. When considering an exception type a cause of ActivityFailureException and ChildWorkflowFailureException is looked at.

        Error and CancellationException are never retried and are not even passed to this filter.

      • build

        public RetryOptions build()
        Build RetryOptions without performing validation as validation should be done after merging with MethodRetry.
      • validateBuildWithDefaults

        public RetryOptions validateBuildWithDefaults()
        Validates property values and builds RetryOptions with default values.