Skip to content
Snippets Groups Projects
Commit c9ccc087 authored by Neelesh Thakur's avatar Neelesh Thakur
Browse files

switch to exponential backoff instead of fixed interval

parent 5233208f
No related branches found
No related tags found
1 merge request!207switch to exponential backoff instead of fixed interval
Pipeline #67792 failed
...@@ -18,6 +18,7 @@ import com.google.gson.JsonArray; ...@@ -18,6 +18,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import io.github.resilience4j.core.IntervalFunction;
import io.github.resilience4j.retry.RetryConfig; import io.github.resilience4j.retry.RetryConfig;
import lombok.Data; import lombok.Data;
import lombok.extern.java.Log; import lombok.extern.java.Log;
...@@ -27,7 +28,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -27,7 +28,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.time.Duration;
import java.util.function.Predicate; import java.util.function.Predicate;
/** /**
...@@ -44,8 +44,8 @@ public class RetryPolicy { ...@@ -44,8 +44,8 @@ public class RetryPolicy {
@Autowired @Autowired
private JaxRsDpsLog logger; private JaxRsDpsLog logger;
private int attempts = 3; private static int MAX_ATTEMPTS = 5;
private int waitDuration = 1000; private static int INITIAL_DELAY = 1000;
private final String RECORD_NOT_FOUND = "notFound"; private final String RECORD_NOT_FOUND = "notFound";
/** /**
...@@ -53,8 +53,8 @@ public class RetryPolicy { ...@@ -53,8 +53,8 @@ public class RetryPolicy {
*/ */
public RetryConfig retryConfig(Predicate<HttpResponse> predicate) { public RetryConfig retryConfig(Predicate<HttpResponse> predicate) {
return RetryConfig.<HttpResponse>custom() return RetryConfig.<HttpResponse>custom()
.maxAttempts(attempts) .maxAttempts(MAX_ATTEMPTS)
.waitDuration(Duration.ofMillis(waitDuration)) .intervalFunction(IntervalFunction.ofExponentialBackoff(INITIAL_DELAY, 2))
.retryOnResult(predicate) .retryOnResult(predicate)
.build(); .build();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment