Java 卡夫卡消费者内补偿的一致性

Java 卡夫卡消费者内补偿的一致性,java,apache-kafka,kafka-consumer-api,Java,Apache Kafka,Kafka Consumer Api,我有一个复制因子为3的卡夫卡主题和min.insync.replicas=2,这是一个制作人,用acks=all向这个主题发送X条消息。 在发送到主题的所有消息之后一段时间(1分钟内),使用java kafka客户端为此主题创建新的使用者。使用consumer.endOffsets()方法获取此主题的所有kafka分区的结束偏移量。对同一方法的另一次调用consumer.endoffset有时会为某些分区返回不同的结束偏移量 在此设置中,在创建使用者之后,不会向kafka topic发送新消息

我有一个复制因子为3的卡夫卡主题和
min.insync.replicas=2
,这是一个制作人,用
acks=all
向这个主题发送X条消息。 在发送到主题的所有消息之后一段时间(1分钟内),使用java kafka客户端为此主题创建新的使用者。使用
consumer.endOffsets()
方法获取此主题的所有kafka分区的结束偏移量。对同一方法的另一次调用
consumer.endoffset
有时会为某些分区返回不同的结束偏移量

在此设置中,在创建使用者之后,不会向kafka topic发送新消息

根据
endoffset
的java文档:

/**
     * 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.
     *
     * <p>
     * This method does not change the current consumer position of the partitions.
     * <p>
     * When {@code isolation.level=read_committed} the last offset will be the Last Stable Offset (LSO).
     * This is the offset of the first message with an open transaction. The LSO moves forward as transactions
     * are completed.
     *
     * @see #seekToEnd(Collection)
     *
     * @param partitions the partitions to get the end offsets.
     * @return The end offsets for the given partitions.
     * @throws org.apache.kafka.common.errors.AuthenticationException if authentication fails. See the exception for more details
     * @throws org.apache.kafka.common.errors.AuthorizationException if not authorized to the topic(s). See the exception for more details
     * @throws org.apache.kafka.common.errors.TimeoutException if the offsets could not be fetched before
     *         expiration of the configured {@code request.timeout.ms}
     */
    @Override
    public Map<TopicPartition, Long> endOffsets(Collection<TopicPartition> partitions) 
/**
*获取给定分区的最后一个偏移量。分区的最后一个偏移量是下一个分区的偏移量
*消息,即最后一条可用消息的偏移量+1。如果消息从未被写过
*对于分区,返回的偏移量将为0。
*
*
*此方法不会更改分区的当前使用者位置。
*
*当{@code isolation.level=read_committed}时,最后一个偏移量将是最后一个稳定偏移量(LSO)。
*这是具有打开事务的第一条消息的偏移量。LSO作为事务向前移动
*全部完成。
*
*@see#seekToEnd(收藏)
*
*@param对分区进行分区以获取结束偏移量。
*@返回给定分区的结束偏移量。
*@如果身份验证失败,则抛出org.apache.kafka.common.errors.AuthenticationException。有关更多详细信息,请参见异常
*@throws org.apache.kafka.common.errors.AuthorizationException(如果未授权主题)。有关更多详细信息,请参见异常
*@throws org.apache.kafka.common.errors.TimeoutException(如果之前无法获取偏移量)
*配置的{@code request.timeout.ms}过期
*/
@凌驾
公共映射内偏移(集合分区)
endOffsets返回最后一个稳定偏移量(LSO),该偏移量由所有副本确认

为什么有时候(不是很经常)在这个方法的后续调用之间结束偏移量会发生变化? 内偏移最终是一致的,这是预期行为吗?虫子