From d261f21700db6a76b53b8a3602ad1b4b302dd4f8 Mon Sep 17 00:00:00 2001 From: Marco Chan Date: Mon, 12 Aug 2024 16:47:16 +0100 Subject: [PATCH] Fix seek-to-timestamp - if the specified timestamp exceeds that of any previously written message then the consumer offset should be set to .endOffsets - incrementing .endOffsets by one will cause a message to missed --- src/jackdaw/client.clj | 2 +- test/jackdaw/client_test.clj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jackdaw/client.clj b/src/jackdaw/client.clj index cbcd0bd7..3692677d 100644 --- a/src/jackdaw/client.clj +++ b/src/jackdaw/client.clj @@ -293,7 +293,7 @@ {:keys [^OffsetAndTimestamp ts-offset end-offset]}] offsets] (let [offset (or (when ts-offset (.offset ts-offset)) - (inc end-offset))] + end-offset)] (log/infof "Setting starting offset (topic=%s, partition=%s): %s" (.topic topic-partition) (.partition topic-partition) diff --git a/test/jackdaw/client_test.clj b/test/jackdaw/client_test.clj index 5374c3bb..18f8d2bb 100644 --- a/test/jackdaw/client_test.clj +++ b/test/jackdaw/client_test.clj @@ -361,5 +361,5 @@ (client/assign-all $ (map :topic-name [topic-config])) (client/seek-to-timestamp $ ts-next [topic-config]) (client/position-all $) - (is (= [11] + (is (= [10] (vals $))))))))))