I would like to get the offset for a kafka topic.
I tried the code mentioned here: https://stackoverflow.com/a/44685608/2762279 but it isn't working.
I found that getting the offsets requires a partition parameter end_offsets(partitions)
.
So, I used the underlying code to find the partitions for the topic however it returns a None
.
from kafka import KafkaConsumer
topic = 'TOPIC'
consumer = KafkaConsumer(
topic,
bootstrap_servers=['IP:PORT'],
client_id = 'CLI',
group_id='GR',
auto_offset_reset='earliest',
consumer_timeout_ms=10000)
print(consumer.partitions_for_topic(topic))
Should i call a method (some sort of connect) before getting the partitions?