Eindeutigere Methodennamen in `BackOffState`
authorKai Moritz <kai@juplo.de>
Fri, 10 Jan 2025 16:34:46 +0000 (17:34 +0100)
committerKai Moritz <kai@juplo.de>
Fri, 24 Jan 2025 19:42:18 +0000 (20:42 +0100)
src/main/java/de/juplo/kafka/BackOffState.java
src/main/java/de/juplo/kafka/ExampleConsumer.java

index b656b10..e06b8b7 100644 (file)
@@ -71,12 +71,12 @@ class BackOffState
     }
   }
 
-  boolean isRetryInProgress(long offset)
+  boolean isStarted(long offset)
   {
     return this.offset == offset && timeNextRetryIsDue != null;
   }
 
-  boolean isUnsuccessful()
+  boolean isCompleted()
   {
     return backOffExecution == null && timeNextRetryIsDue != null;
   }
@@ -91,7 +91,7 @@ class BackOffState
     return Duration.between(startTime, timeNextRetryIsDue);
   }
 
-  void markRetryAsSuccessful()
+  void markAsCompleted()
   {
     if (backOffExecution != null)
     {
index 6cf4bd0..6465a58 100644 (file)
@@ -146,7 +146,7 @@ public class ExampleConsumer implements ConsumerRebalanceListener, Runnable
                 // Seeking to the offset of the record, that raised the exception, and
                 // leaving the loop afterwards, retries the record
                 int partition = topicPartition.partition();
-                if (!backOffState[partition].isRetryInProgress(record.offset()))
+                if (!backOffState[partition].isStarted(record.offset()))
                 {
                   log.info(
                     "{} - First occurrence of a retryable error for offset={} in partition {} - Initializing retry!",
@@ -159,7 +159,7 @@ public class ExampleConsumer implements ConsumerRebalanceListener, Runnable
                 }
                 else
                 {
-                  if (backOffState[partition].isUnsuccessful())
+                  if (backOffState[partition].isCompleted())
                   {
                     log.warn(
                       "{} - Ignoring retryable error after {} attempts and {}",
@@ -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()].markAsCompleted();
             }
           }
         }