From: Kai Moritz Date: Sun, 24 Sep 2023 19:39:01 +0000 (+0200) Subject: fix: The actual position has to be requested from the consumer X-Git-Tag: rebase--2024-01-27--15-10~1 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=51e150afbe6130d4fb6c8e8fda12732c7b083651;p=demos%2Fkafka%2Fchat fix: The actual position has to be requested from the consumer * If the last seen offset and the current offset differ, although the partition did not contain any messages between this offsets, the loading process got stuck, because the position never advanced. * Therefore, the actual position, that is compared against the read end-offset, has to be requested from the consumer. --- diff --git a/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/DataChannel.java b/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/DataChannel.java index c2908461..5680360f 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/DataChannel.java +++ b/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/DataChannel.java @@ -279,7 +279,12 @@ public class DataChannel implements Runnable, ConsumerRebalanceListener return IntStream .range(0, numShards) .filter(shard -> isShardOwned[shard]) - .allMatch(shard -> nextOffset[shard] >= currentOffset[shard]); + .allMatch(shard -> + { + TopicPartition partition = new TopicPartition(topic, shard); + long position = consumer.position(partition); + return position >= currentOffset[shard]; + }); } private void pauseAllOwnedPartions()