Rafctor params

This commit is contained in:
k.struzhkin 2020-01-20 11:25:58 +03:00
parent 50ca2ed1dd
commit 0c705f2fc7
2 changed files with 10 additions and 4 deletions

View File

@ -1,5 +1,6 @@
package com.rbkmoney.cm.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.retry.annotation.EnableRetry;
@ -11,19 +12,21 @@ import org.springframework.retry.support.RetryTemplate;
@Configuration
public class RetryConfig {
public static final long BACK_OFF_PERIOD = 1000l;
public static final int MAX_ATTEMPTS = 3;
@Value("${event.sink.retry.backoff.period:1000}")
private long backOffPeriod;
@Value("${event.sink.retry.max.attempts:3}")
private int maxAttempts;
@Bean
public RetryTemplate retryTemplate() {
RetryTemplate retryTemplate = new RetryTemplate();
FixedBackOffPolicy fixedBackOffPolicy = new FixedBackOffPolicy();
fixedBackOffPolicy.setBackOffPeriod(BACK_OFF_PERIOD);
fixedBackOffPolicy.setBackOffPeriod(backOffPeriod);
retryTemplate.setBackOffPolicy(fixedBackOffPolicy);
SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
retryPolicy.setMaxAttempts(MAX_ATTEMPTS);
retryPolicy.setMaxAttempts(maxAttempts);
retryTemplate.setRetryPolicy(retryPolicy);
return retryTemplate;

View File

@ -63,3 +63,6 @@ kafka:
key-password: kenny
server-password: kenny12
server-keystore-location: src/main/resources/cert/truststore.p12
event.sink.retry:
backoff.period: 1000
max.attempts: 3