'pykafka consumes same messages
Pykafka Kafkaconsumer consumes same messages from beginning everytime.
def consume_from_kafka():
client = KafkaClient(hosts=IP)
topic = client.topics[TOPIC]
consumer = topic.get_simple_consumer(consumer_group="mygroup",reset_offset_on_start=True)
consumer.commit_offsets()
for message in consumer:
if message is not None:
print(message.offset, message.value)
Solution 1:[1]
reset_offset_on_start=True
https://pykafka.readthedocs.io/en/latest/usage.html
For any existing group/topic/partitions, assuming reset_offset_on_start=False, consumption will start from the offset immediately following the last committed offset (if the last committed offset was 4, consumption starts at 5). If reset_offset_on_start=True, consumption starts from auto_offset_reset. If there is no committed offset, the group/topic/partition is considered new.
Move consumer.commit_offsets() after the loop, or into it
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 |
