From fd3116a0c32a38d457c04c8db0a0bd01ee033194 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 10 Jan 2025 17:34:46 +0100 Subject: [PATCH] Eindeutigere Methodennamen in `BackOffState` --- src/main/java/de/juplo/kafka/BackOffState.java | 6 +++--- src/main/java/de/juplo/kafka/ExampleConsumer.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/juplo/kafka/BackOffState.java b/src/main/java/de/juplo/kafka/BackOffState.java index b656b10c..e06b8b74 100644 --- a/src/main/java/de/juplo/kafka/BackOffState.java +++ b/src/main/java/de/juplo/kafka/BackOffState.java @@ -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) { diff --git a/src/main/java/de/juplo/kafka/ExampleConsumer.java b/src/main/java/de/juplo/kafka/ExampleConsumer.java index 6cf4bd02..6465a582 100644 --- a/src/main/java/de/juplo/kafka/ExampleConsumer.java +++ b/src/main/java/de/juplo/kafka/ExampleConsumer.java @@ -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(); } } } -- 2.20.1