I put real-time data in kafka, but I wanted to get the data from the beginning of offset. The method is not written in the document, so write it as a memorandum
There seem to be some kafka libraries kafka-I decided to use python 1.3.2
from kafka import KafkaConsumer, TopicPartition
consumer = KafkaConsumer(bootstrap_servers='hoge')
tp = TopicPartition('topic_name', 0)
consumer.assign([tp])
consumer.seek(tp, 0)
for msg in consumer:
// do something
Specify the topic name using TopicPartition without specifying the topic in the constructor of KafkaConsumer. After that, you can specify Topic Partition and offset in seek.
Recommended Posts