From c9ccc0871a2c2fcf7dde415df2d3d60f6c6b6e86 Mon Sep 17 00:00:00 2001
From: NThakur4 <nthakur4@slb.com>
Date: Fri, 24 Sep 2021 09:04:35 -0500
Subject: [PATCH] switch to exponential backoff instead of fixed interval

---
 .../osdu/indexer/azure/service/RetryPolicy.java        | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/service/RetryPolicy.java b/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/service/RetryPolicy.java
index 40e0d8b2a..85aaa1ee1 100644
--- a/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/service/RetryPolicy.java
+++ b/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/service/RetryPolicy.java
@@ -18,6 +18,7 @@ import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
+import io.github.resilience4j.core.IntervalFunction;
 import io.github.resilience4j.retry.RetryConfig;
 import lombok.Data;
 import lombok.extern.java.Log;
@@ -27,7 +28,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.stereotype.Component;
 
-import java.time.Duration;
 import java.util.function.Predicate;
 
 /**
@@ -44,8 +44,8 @@ public class RetryPolicy {
     @Autowired
     private JaxRsDpsLog logger;
 
-    private int attempts = 3;
-    private int waitDuration = 1000;
+    private static int MAX_ATTEMPTS = 5;
+    private static int INITIAL_DELAY = 1000;
     private final String RECORD_NOT_FOUND = "notFound";
 
     /**
@@ -53,8 +53,8 @@ public class RetryPolicy {
      */
     public RetryConfig retryConfig(Predicate<HttpResponse> predicate) {
         return RetryConfig.<HttpResponse>custom()
-                .maxAttempts(attempts)
-                .waitDuration(Duration.ofMillis(waitDuration))
+                .maxAttempts(MAX_ATTEMPTS)
+                .intervalFunction(IntervalFunction.ofExponentialBackoff(INITIAL_DELAY, 2))
                 .retryOnResult(predicate)
                 .build();
     }
-- 
GitLab