当我尝试运行时抛出空指针错误时,我试图根据时间戳获取 Kafka 主题的偏移量,
Map<TopicPartition, Long> timestampsToSearch = new HashMap<>();
for (TopicPartition partition : partitions) {
timestampsToSearch.put(partition, startTimestamp);
}
Map<TopicPartition, OffsetAndTimestamp> outOffsets = consumer.offsetsForTimes(timestampsToSearch);
for (TopicPartition partition : partitions) {
Long seekOffset = outOffsets.get(partition).offset();
consumer.seek(partition, seekOffset);
任何帮助将不胜感激。
杨__羊羊
白猪掌柜的
相关分类