Validating html documents against whitelist of html tags

You may have a requirement where your application has to accept html data as input from the user and you have to make sure that the input contains only those tag that are allowed by your application. In this post under Jsoup, I will show how to implement the above requirement. First we have to…… Continue reading Validating html documents against whitelist of html tags

Configuring UniformRandomBackOffPolicy for RetryTemplate (using RetryTemplateBuilder)

In this post under Spring Retry, I will show with example how to configure UniformRandomBackOffPolicy using RetryTemplateBuilder. But before that lets recap what is UniformRandomBackOffPolicy. 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. For our example we…… Continue reading Configuring UniformRandomBackOffPolicy for RetryTemplate (using RetryTemplateBuilder)

Configuring FixedBackOffPolicy for RetryTemplate (using RetryTemplateBuilder)

In this post under Spring Retry, I will show with example how to configure FixedBackOffPolicy using RetryTemplateBuilder. Before we start lets just recap what is BackOffPolicy and FixedBackOffPolicy. Backoff policies help us define different policies which will tell Spring Retry how long to wait before retrying a failed operation. FixedBackOffPolicy is one of the implmentations…… Continue reading Configuring FixedBackOffPolicy for RetryTemplate (using RetryTemplateBuilder)

Configuring TimeoutRetryPolicy for RetryTemplate (using RetryTemplateBuilder)

In this post under Spring Retry, I will show with example how to configure TimeoutRetryPolicy using RetryTemplateBuilder. Lets refresh what is TimeoutRetryPolicy. TimeoutRetryPolicy tells Spring retry to retry a failed operation as many times as possible before the timeout happens. Once timeout happens the Spring retry stopsretrying the failed operation. Now lets see how to…… Continue reading Configuring TimeoutRetryPolicy for RetryTemplate (using RetryTemplateBuilder)

Configuring MaxAttemptsRetryPolicy for RetryTemplate (using RetryTemplateBuilder)

In this post under Spring Retry, I will show with example how to configure MaxAttemptsRetryPolicy using RetryTemplateBuilder. Lets refresh what is MaxAttemptsRetryPolicy. MaxAttemptsRetryPolicy tells Spring retry to retry a failed operation for a fixed number of times. Now lets see how to configure using RetryTemplateBuilder. Below is the xml code for your reference XML Code…… Continue reading Configuring MaxAttemptsRetryPolicy for RetryTemplate (using RetryTemplateBuilder)

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)

Combining multiple Retry Policies (using xml)

In this post under Spring Retry, I will show with example how to combine multiple retry policies. Below is the xml configuration XML code 1 <?xml version=”1.0″ encoding=”UTF-8″?> 2 <beans xmlns=”http://www.springframework.org/schema/beans&#8221; 3 xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; 4 xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd”&gt; 5 <bean id=”maxAttemptsRetryPolicy1″ class=”org.springframework.retry.policy.MaxAttemptsRetryPolicy”> 6 <property name=”maxAttempts” value=”3″/> 7 </bean> 8 9 <bean id=”maxAttemptsRetryPolicy2″ class=”org.springframework.retry.policy.MaxAttemptsRetryPolicy”> 10 <property name=”maxAttempts” value=”6″/>…… Continue reading Combining multiple Retry Policies (using xml)