'How to paginate with apache kafka messages

A pagination system is done with total records and specify offset to start paginate.

How can I get total records and offset in kafka from console?



Solution 1:[1]

Kafka doesn't paginate. A topic is a sequential log of events.

However, your consumer group has an initial or stored offset, and on the next poll, will read up to max.poll.records for the next "page" after that offset.

If you want to count the number of records in a non compacted topic, you can use GetOffsetShell tool to query the first and last offset, then subtract the difference. For a compacted topic, there are gaps in those numbers and the only reasonable way to count records is to consume the entire topic

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 OneCricketeer