FIX:double-mark-as-successful
authorKai Moritz <kai@juplo.de>
Fri, 10 Jan 2025 09:46:59 +0000 (10:46 +0100)
committerKai Moritz <kai@juplo.de>
Fri, 10 Jan 2025 09:46:59 +0000 (10:46 +0100)
src/main/java/de/juplo/kafka/BackOffState.java
src/main/java/de/juplo/kafka/ExampleConsumer.java

index 556b3b1..b8a226b 100644 (file)
@@ -95,9 +95,9 @@ class BackOffState
     return Duration.between(startTime, timeNextRetryIsDue);
   }
 
-  void markRetryAsSuccessful()
+  void markRetryAsSuccessful(long offset)
   {
-    if (inProgress)
+    if (inProgress && this.offset == offset)
     {
       Instant now = clock.instant();
       log.info(
index 2ef4b0a..51e69ff 100644 (file)
@@ -185,7 +185,7 @@ public class ExampleConsumer implements ConsumerRebalanceListener, Runnable
                 log.warn("{} - Ignoring non-retryable error!", id, e);
               }
 
-              backOffState[topicPartition.partition()].markRetryAsSuccessful();
+              backOffState[topicPartition.partition()].markRetryAsSuccessful(record.offset());
             }
           }
         }