[ https://issues.apache.org/jira/browse/KAFKA-10009?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17109017#comment-17109017 ]
Yuriy Badalyantc commented on KAFKA-10009: ------------------------------------------ Even with read_committed isolation level {{endOffsets - 1}} will not give you last record offset if producer is transactional. It will point to an offset without a record. I specifically tested this behavior (on 2.4.0). Also, isolation level affects only pending transactions. > Add method for getting last record offset in kafka partition > ------------------------------------------------------------ > > Key: KAFKA-10009 > URL: https://issues.apache.org/jira/browse/KAFKA-10009 > Project: Kafka > Issue Type: New Feature > Components: clients, consumer > Reporter: Yuriy Badalyantc > Priority: Minor > > As far as I understand, at the current moment, there is no reliable way for > getting offset of the last record in the partition using java client. There > is {{endOffsets}} method in the consumer. And usually {{endOffsets - 1}} > works fine. But in the case of transactional producer, topic may contain > offsets without a record. And {{endOffsets - 1}} will point to the offset > without record. > This feature will help in situations when consumer application wants to > consume the whole topic. Checking of beginning and last record offset will > give lower and upper bounds for consuming. Of course, it is doable with the > current consumer implementation, but I need to check {{position}} after each > poll. > Also, I believe that this feature may help with monitoring and operations. -- This message was sent by Atlassian Jira (v8.3.4#803005)