Kafka python consumers re-reading all the part

2019-08-26 05:14发布

I created kafka partitions, but when I run multiple consumers all the consumers are reading the same message of all the partitions. Here goes my sample code.

from kafka import KafkaClient, SimpleConsumer 
from kafka import KafkaConsumer 
from sys 
import argv 
import time 
consumer = KafkaConsumer("abc", group_id='my-group', bootstrap_servers=['my-server']) 
for message in consumer: 
       #time.sleep(6) 
       print "PARTITION "+str(message[1])+" OFFSET: "+str(message[2])+"\t MSG: "+str(message[4])
       consumer.commit() 

0条回答
登录 后发表回答