software.amazon.awssdk.core.retry.backoff.FullJitterBackoffStrategy Java Examples

The following examples show how to use software.amazon.awssdk.core.retry.backoff.FullJitterBackoffStrategy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SqsAutoConfiguration.java    From synapse with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(name = "sqsRetryPolicy", value = RetryPolicy.class)
public RetryPolicy sqsRetryPolicy() {
    return RetryPolicy.defaultRetryPolicy().toBuilder()
            .retryCondition(defaultRetryCondition())
            .numRetries(Integer.MAX_VALUE)
            .backoffStrategy(FullJitterBackoffStrategy.builder()
                    .baseDelay(Duration.ofSeconds(1))
                    .maxBackoffTime(SdkDefaultRetrySetting.MAX_BACKOFF)
                    .build())
            .build();
}
 
Example #2
Source File: KinesisAutoConfiguration.java    From synapse with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(name = "kinesisRetryPolicy", value = RetryPolicy.class)
public RetryPolicy kinesisRetryPolicy() {
    return RetryPolicy.defaultRetryPolicy().toBuilder()
            .retryCondition(new DefaultLoggingRetryCondition(5, 10))
            .numRetries(Integer.MAX_VALUE)
            .backoffStrategy(FullJitterBackoffStrategy.builder()
                    .baseDelay(Duration.ofSeconds(1))
                    .maxBackoffTime(SdkDefaultRetrySetting.MAX_BACKOFF)
                    .build())
            .build();
}
 
Example #3
Source File: AsyncSqsClientFactory.java    From dynein with Apache License 2.0 4 votes vote down vote up
private RetryPolicy buildRetryPolicy(RetryPolicyConfiguration config) {
  RetryPolicy retryPolicy;

  if (config == null) {
    retryPolicy = RetryPolicy.none();
  } else {
    switch (config.getPolicy()) {
      case DEFAULT:
        retryPolicy = RetryPolicy.defaultRetryPolicy();
        break;
      case NONE:
        retryPolicy = RetryPolicy.none();
        break;
      default:
        RetryCondition condition;
        BackoffStrategy strategy;

        switch (config.getCondition()) {
          case DEFAULT:
            condition = RetryCondition.defaultRetryCondition();
            break;
          case MAX_NUM:
            condition = MaxNumberOfRetriesCondition.create(config.getNumRetries());
            break;
          default:
            condition = RetryCondition.none();
        }

        switch (config.getBackOff()) {
          case FULL_JITTER:
            strategy =
                FullJitterBackoffStrategy.builder()
                    .baseDelay(Duration.ofMillis(config.getBaseDelay()))
                    .maxBackoffTime(Duration.ofMillis(config.getMaximumBackoffTime()))
                    .build();
            break;
          case EQUAL_JITTER:
            strategy =
                EqualJitterBackoffStrategy.builder()
                    .baseDelay(Duration.ofMillis(config.getBaseDelay()))
                    .maxBackoffTime(Duration.ofMillis(config.getMaximumBackoffTime()))
                    .build();
            break;
          case FIXED_DELAY:
            strategy = FixedDelayBackoffStrategy.create(Duration.ofMillis(config.getBaseDelay()));
            break;
          case DEFAULT:
            strategy = BackoffStrategy.defaultStrategy();
            break;
          case DEFAULT_THROTTLE:
            strategy = BackoffStrategy.defaultThrottlingStrategy();
            break;
          default:
            strategy = BackoffStrategy.none();
        }

        retryPolicy =
            RetryPolicy.builder()
                .numRetries(config.getNumRetries())
                .retryCondition(condition)
                .backoffStrategy(strategy)
                .build();
    }
  }

  return retryPolicy;
}