Retry java RestTemplate HTTP request if host offline
I had same situation and done some googling found the solution. Giving answer in hope it help someone else. You can set max try and time interval for each try. @Bean public RetryTemplate retryTemplate() { int maxAttempt = Integer.parseInt(env.getProperty(“maxAttempt”)); int retryTimeInterval = Integer.parseInt(env.getProperty(“retryTimeInterval”)); SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(); retryPolicy.setMaxAttempts(maxAttempt); FixedBackOffPolicy backOffPolicy = new FixedBackOffPolicy(); backOffPolicy.setBackOffPeriod(retryTimeInterval); … Read more