projects
/
demos
/
kafka
/
chat
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refactor: separated message- and record- (aka offset-) handling
[demos/kafka/chat]
/
src
/
main
/
java
/
de
/
juplo
/
kafka
/
chat
/
backend
/
implementation
/
kafka
/
DataChannel.java
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
ec6079b
..
2c3e60a
100644
(file)
--- 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
@@
-169,6
+169,7
@@
public class DataChannel implements Runnable, ConsumerRebalanceListener
{
int partition = topicPartition.partition();
isShardOwned[partition] = false;
{
int partition = topicPartition.partition();
isShardOwned[partition] = false;
+ nextOffset[partition] = consumer.position(topicPartition);
log.info("Partition revoked: {} - next={}", partition, nextOffset[partition]);
infoChannel.sendShardRevokedEvent(partition);
});
log.info("Partition revoked: {} - next={}", partition, nextOffset[partition]);
infoChannel.sendShardRevokedEvent(partition);
});
@@
-284,7
+285,12
@@
public class DataChannel implements Runnable, ConsumerRebalanceListener
return IntStream
.range(0, numShards)
.filter(shard -> isShardOwned[shard])
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()
}
private void pauseAllOwnedPartions()