Logging in `BackOffState` verbessert
authorKai Moritz <kai@juplo.de>
Fri, 10 Jan 2025 14:03:49 +0000 (15:03 +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

index 92d08df..b656b10 100644 (file)
@@ -55,16 +55,18 @@ class BackOffState
       return false;
     }
 
-    if (clock.instant().isAfter(timeNextRetryIsDue))
+    Instant now = clock.instant();
+    Duration remaining = Duration.between(now, timeNextRetryIsDue);
+    if (remaining.isNegative())
     {
       numRetries++;
+      log.info("{} - {}. retry for {}, lateness: {}", id, numRetries, topicPartition, remaining.abs());
       initializeNextBackOff();
-      log.info("{} - Retrying {}", id, topicPartition);
       return false;
     }
     else
     {
-      log.info("{} - Next retry for {} is due at {}", id, topicPartition, timeNextRetryIsDue);
+      log.info("{} - Next retry for {} is due in {}", id, topicPartition, remaining);
       return true;
     }
   }