Commit fe0b2490 by 杨林龙

z-gps-kafka-consumer-test-pingan30

1 parent 55b81923
from kafka import KafkaConsumer
# 创建Kafka消费者
consumer = KafkaConsumer(
"gps_gpsandbs_pingan2", # Kafka主题名称
bootstrap_servers="192.168.3.131:9092", # Kafka集群的地址
group_id="my-yang-group", # 消费者组ID
)
# 循环消费消息
for message in consumer:
# 从消息中获取键和值
key = message.key
value = message.value
print(f"Key: {key}, Value: {value}")
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!