1from kafka import SimpleClient
2from kafka.protocol.offset import OffsetRequest, OffsetResetStrategy
3from kafka.common import OffsetRequestPayload
4
5client = SimpleClient(brokers)
6
7partitions = client.topic_partitions[topic]
8offset_requests = [OffsetRequestPayload(topic, p, -1, 1) for p in partitions.keys()]
9
10offsets_responses = client.send_offset_request(offset_requests)
11
12for r in offsets_responses:
13 print "partition = %s, offset = %s"%(r.partition, r.offsets[0])