Python Kafka consumer missing to poll some messages

前端 未结 1 1443
独厮守ぢ
独厮守ぢ 2021-01-23 08:08

The code for my Kafka consumer looks like this

def read_messages_from_kafka():
    topic = \'my-topic\'
    consumer = KafkaConsumer(
        bootstrap_servers=[         


        
相关标签:
1条回答
  • 2021-01-23 08:15

    There is a problem of missing messages in your Kafka client. I found solution here:

    while True:
        raw_messages = consumer.poll(timeout_ms=1000, max_records=5000)
        for topic_partition, messages in raw_messages.items():
            application_message = json.loads(message.value.decode())
    

    Also there is another Kafka client exists: confluent_kafka. It has no such problem.

    0 讨论(0)
提交回复
热议问题