我有min.insync.replicas = 2一个复制因子为 3 的 kafka 主题,一个生产者使用acks=all. 一段时间后(在 1 分钟内),使用 java kafka 客户端为此主题创建了所有发送到该主题的新消费者的消息。consumer.endOffsets()获取此主题的所有 kafka 分区的使用方法结束偏移量。同一方法的另一个调用consumer.endOffsets有时会为某些分区返回不同的结束偏移量。
在此设置中,创建消费者后没有新消息发送到 kafka 主题。
根据java文档endOffsets:
/**
* Get the last offset for the given partitions. The last offset of a partition is the offset of the upcoming
* message, i.e. the offset of the last available message + 1. If messages have never been written
* to the the partition, the offset returned will be 0. …Run Code Online (Sandbox Code Playgroud)