Class RetryConfig


  • @Configuration
    @EnableAspectJAutoProxy
    public class RetryConfig
    extends Object
    The Class RetryConfig - to configure retry template with retry/back off policies as per configuration.
    Author:
    Loganathan Sekar
    • Constructor Detail

      • RetryConfig

        public RetryConfig()
    • Method Detail

      • retryPolicy

        @Bean
        public org.springframework.retry.RetryPolicy retryPolicy​(@Value("${kernel.retry.attempts.limit:5}")
                                                                 int retryLimit,
                                                                 @Value("${kernel.retry.traverse.root.cause.enabled:true}")
                                                                 boolean traverseRootCause)
        Retry policy.
        Parameters:
        retryLimit - the retry limit
        Returns:
        the retry policy
      • getRetryableExceptionsFromConfig

        protected Map<Class<? extends Throwable>,​Boolean> getRetryableExceptionsFromConfig()
        Gets the retryable exceptions from config.
        Returns:
        the retryable exceptions from config
      • backOffPolicy

        @Bean
        public org.springframework.retry.backoff.BackOffPolicy backOffPolicy​(@Value("${kernel.retry.exponential.backoff.initial.interval.millisecs:200}")
                                                                             long initialIntervalMilliSecs,
                                                                             @Value("${kernel.retry.exponential.backoff.multiplier:1.0}")
                                                                             double multiplier,
                                                                             @Value("${kernel.retry.exponential.backoff.max.interval.millisecs:5000}")
                                                                             long maxIntervalMilliSecs)
        Back off policy.
        Parameters:
        initialIntervalMilliSecs - the initial interval milli secs
        multiplier - the multiplier
        maxIntervalMilliSecs - the max interval milli secs
        Returns:
        the back off policy
      • retryTemplate

        @Bean
        public org.springframework.retry.support.RetryTemplate retryTemplate​(org.springframework.retry.RetryPolicy retryPolicy,
                                                                             org.springframework.retry.backoff.BackOffPolicy backOffPolicy,
                                                                             org.springframework.retry.RetryListener retryListener)
        Retry template.
        Parameters:
        retryPolicy - the retry policy
        backOffPolicy - the back off policy
        retryListener - the retry listener
        Returns:
        the retry template