Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Kafka使用者在分配给多个分区时不使用任何消息_Python_Apache Kafka - Fatal编程技术网

Python Kafka使用者在分配给多个分区时不使用任何消息

Python Kafka使用者在分配给多个分区时不使用任何消息,python,apache-kafka,Python,Apache Kafka,我有一个kafka主题,它有100个分区,每个分区大约有100000条消息。我希望我的消费者开始阅读第一条消息,因此我使用随机组id对其进行配置,并将自动偏移重置设置为最早 from kafka import KafkaConsumer config = { 'bootstrap_servers': bootstrapServers, 'group_id': str(uuid.uuid4()), 'client_id': 'test', 'enable_auto_commit': False

我有一个kafka主题,它有100个分区,每个分区大约有100000条消息。我希望我的消费者开始阅读第一条消息,因此我使用随机组id对其进行配置,并将自动偏移重置设置为最早

from kafka import KafkaConsumer

config = { 
'bootstrap_servers': bootstrapServers,
'group_id': str(uuid.uuid4()),
'client_id': 'test',
'enable_auto_commit': False,
'auto_offset_reset': 'earliest',
'max_partition_fetch_bytes': 50*1024*1024
}

consumer = KafkaConsumer(**config)
我正在使用consumer.assign为我的使用者分配分区。如果我将其分配到50个分区或更多分区,则使用者从不读取任何消息,但如果我将其分配到更少的分区,则它会正常读取所有消息

while(True):
    pollResult = consumer.poll()
    readMessages = []
    for partition, messages in six.iteritems(pollResult):
        if messages:
            logger.info("Found messages in partition {}".format(partition))
            readessages.extend(messages)
        else:
            logger.info("No messages in partition {}".format(partition))
    logger.info("Total messages read: {}".format(len(readMessages)))
当我将消费者分配到50个分区时,我在日志中看到的只是“读取的消息总数:0”。 我尝试使用auto_offset_reset='latest',并将其分配到50个甚至100个分区,它读取发送给kafka的任何新消息,但我需要读取所有消息,而不仅仅是启动消费者后发送的消息

我错过什么了吗?消费者能够阅读的最大消息量是多少?如果是,是否可配置