python kafka specifies the consumer name

#!/usr/bin/env python
# coding=utf-8
"""
    Kafka's consumers are not thread-safe and cannot be multi-threaded.
    Kafka is not like other MQs. After consuming the data, it will be discarded directly, but will be stored by default. 7 days, automatically cleared after 7 days of storage, so you can start consumption from the beginning and
    start consumption from the specified setoff of the partition of the specified topic
"""

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)

 

Guess you like

Origin blog.csdn.net/zhaoyangjian724/article/details/131167558