X-Git-Url: http://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fde%2Fjuplo%2Fkafka%2Fchat%2Fbackend%2Fimplementation%2Fkafka%2FDataChannel.java;h=8dcc1bce8315323dc6e2e5f547087809351b9835;hb=075fbbf0c290748fa8b6d684c145a2f1ab8cbe0d;hp=2468af5ab004a8bf028abfb57d687890eb007cfa;hpb=5168b2e2a25b5890fe39ea5fba16688f81b3d3a2;p=demos%2Fkafka%2Fchat 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 2468af5a..8dcc1bce 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 @@ -36,7 +36,7 @@ public class DataChannel implements Channel, ConsumerRebalanceListener private final ZoneId zoneId; private final int numShards; private final Duration pollingInterval; - private final int bufferSize; + private final int historyLimit; private final Clock clock; private final boolean[] isShardOwned; private final long[] currentOffset; @@ -58,7 +58,7 @@ public class DataChannel implements Channel, ConsumerRebalanceListener ZoneId zoneId, int numShards, Duration pollingInterval, - int bufferSize, + int historyLimit, Clock clock, ChannelMediator channelMediator, ShardingPublisherStrategy shardingPublisherStrategy) @@ -75,7 +75,7 @@ public class DataChannel implements Channel, ConsumerRebalanceListener this.zoneId = zoneId; this.numShards = numShards; this.pollingInterval = pollingInterval; - this.bufferSize = bufferSize; + this.historyLimit = historyLimit; this.clock = clock; this.isShardOwned = new boolean[numShards]; this.currentOffset = new long[numShards]; @@ -176,6 +176,9 @@ public class DataChannel implements Channel, ConsumerRebalanceListener partitions.forEach(topicPartition -> { int partition = topicPartition.partition(); + chatRoomData[partition] + .values() + .forEach(chatRoomData -> chatRoomData.close()); isShardOwned[partition] = false; nextOffset[partition] = consumer.position(topicPartition); log.info("Partition revoked: {} - next={}", partition, nextOffset[partition]); @@ -355,9 +358,9 @@ public class DataChannel implements Channel, ConsumerRebalanceListener } else { - log.info("Creating ChatRoomData {} with buffer-size {}", chatRoomId, bufferSize); + log.info("Creating ChatRoomData {} with history-limit {}", chatRoomId, historyLimit); KafkaChatMessageService service = new KafkaChatMessageService(this, chatRoomId); - chatRoomData = new ChatRoomData(clock, service, bufferSize); + chatRoomData = new ChatRoomData(clock, service, historyLimit); this.chatRoomData[shard].put(chatRoomId, chatRoomData); }