最近在用kafka要求是多个消费者消费同一个topic,在网上找了很多最后才确定加入
auto_commit_enable=True
下边把我的消费者代码给贴出来
client = KafkaClient(hosts="127.0.0.1:9092") topic = client.topics[b"PD_Topic"] #if you want to consumer next time,you can change the consumer_group consumer=topic.get_simple_consumer(consumer_group='sec3',auto_commit_enable=True,auto_commit_interval_ms=1,consumer_id='c1') for message in consumer: if message is not None: print(message.value.decode())