python kafka 指定消费者名字

#!/usr/bin/env python
# coding=utf-8
"""
    kafka的消费者不是线程安全的,不能多线程启用
    kafka不像其他的MQ,消费完数据,直接丢掉,而是会默认存储7天,存储7天后自动清除,故而可以从头开始消费
    从指定topic的partiotion的指定setoff开始消费
"""

import json
from kafka import KafkaConsumer
from kafka.structs import TopicPartition

consumer = KafkaConsumer(bootstrap_servers='192.168.137.200:9092',group_id='python3-consumer',
                         auto_offset_reset='earliest')
consumer.subscribe(['topic_elink'])
for message in consumer:
    print(message)

猜你喜欢

转载自blog.csdn.net/zhaoyangjian724/article/details/131167558