Configuring RetryListener for RetryTemplate (using RetryTemplateBuilder)

In this post under Spring Retry, I will show with example how to configure RetryListener using RetryTemplateBuilder class. First we will create a custom listener class which implements RetryListener interface as shown below CustomRetryListener1 import org.springframework.retry.RetryCallback; import org.springframework.retry.RetryContext; import org.springframework.retry.RetryListener; public class CustomRetryListener1 implements RetryListener { @Override public <T, E extends Throwable> void close(RetryContext arg0,…… Continue reading Configuring RetryListener for RetryTemplate (using RetryTemplateBuilder)

ExponentialBackOffPolicy Example (using xml configuration)

In this post under Spring Retry, I will introduce with example another out of the box implementation of BackOffPolicy i.e., ExponentialBackOffPolicy. ExponentialBackOffPolicy increases the backoff period at every retry attempt by a specified number. ExponentialBackOffPolicy requires three inputs for it to work, which are1) initialInterval –> the backoff period used at first retry2) maxInterval –>…… Continue reading ExponentialBackOffPolicy Example (using xml configuration)

UniformRandomBackOffPolicy Example (using xml configuration)

In this post under Spring Retry, I will explain with example how to use UniformRandomBackOffPolicy (another implementation of BackOffPolicy interface). UniformRandomBackOffPolicy chooses a random time in ms between user configured MinBackOffPeriod and MaxBackOffPeriod and then before a failed operations is retried, it pauses for that time. Below is the xml configuration code. XML code 1…… Continue reading UniformRandomBackOffPolicy Example (using xml configuration)

FixedBackOffPolicy Simple Example (using xml configuration)

In this post under Spring Retry, I will explain backoff policy concept with example. In Spring Retry, when an operation fails, it is immediately retried but if you want Spring Retry to wait for some time before retrying, you can take help of backoff policies. Backoff policies help us define different policies which will tell…… Continue reading FixedBackOffPolicy Simple Example (using xml configuration)