python 查看kafka发送的消息格式及消息内容

from pykafka import KafkaClient

client = KafkaClient(hosts="10.37.22.176:9092")
topic = client.topics[b'rtz_am_queue']    #topic名称
consumer = topic.get_simple_consumer()
for record in consumer:
    if record is not None:
        valuestr = record.value.decode()   #从bytes转为string类型
        # valuedict = eval(valuestr)
        # message = valuedict["message"]
        str_ = str(valuestr).split("|")
        if str_[3] == "34004":
            print(valuestr)

猜你喜欢

转载自blog.csdn.net/sxf_123456/article/details/82356320
今日推荐