• SimpleRetryTemplateSupplier


    import java.util.Map;
    
    import org.springframework.retry.backoff.FixedBackOffPolicy;
    import org.springframework.retry.policy.SimpleRetryPolicy;
    import org.springframework.retry.support.RetryTemplate;
    
    import com.citi.simpliciti.tempest.util.RawSerializableSupplier;
    
    public class SimpleRetryTemplateSupplier implements RawSerializableSupplier<RetryTemplate> {
    
      private int maxAttempts;
      private int backOffPeriod;
      private Map<Class<? extends Throwable>, Boolean> retryableExceptions;
    
      private transient RetryTemplate retryTemplate;
    
      public SimpleRetryTemplateSupplier(int maxAttempts, int backOffPeriod,
          Map<Class<? extends Throwable>, Boolean> retryableExceptions) {
        this.maxAttempts = maxAttempts;
        this.backOffPeriod = backOffPeriod;
        this.retryableExceptions = retryableExceptions;
      }
    
    
      @Override
      public RetryTemplate get() {
        if (retryTemplate == null) {
          SimpleRetryPolicy policy = new SimpleRetryPolicy(maxAttempts, retryableExceptions);
    
          FixedBackOffPolicy fixedBackOffPolicy = new FixedBackOffPolicy();
          fixedBackOffPolicy.setBackOffPeriod(backOffPeriod);
    
          retryTemplate = new RetryTemplate();
          retryTemplate.setRetryPolicy(policy);
          retryTemplate.setBackOffPolicy(fixedBackOffPolicy);
        }
        return retryTemplate;
    
      }
    }
     @Bean
      public SimpleRetryTemplateSupplier tpsPositionRetryTemplateSupplier() {
        return new SimpleRetryTemplateSupplier(maxAttempts, backOffPeriod,
            ImmutableMap.of(RestClientException.class, true, JsonSyntaxException.class, true));
      }
  • 相关阅读:
    LeNet && ModernCNN
    Fundamentals of Convolutional Neural Networks
    机器及其相关技术介绍
    学而后思,方能发展;思而立行,终将卓越
    贪心的区间问题
    基环树
    模板类
    存储问题
    大佬们的技巧
    exgcd
  • 原文地址:https://www.cnblogs.com/tonggc1668/p/9254307.html
Copyright © 2020-2023  润新知