I wish to consume a specific number of maximum messages per consume from a kafka topic. I have used the following code:
consumer = KafkaConsumer(topic, bootstrap_servers=[server], max_poll_records=2, api_version=(0, 10))
for message in consumer:
string = message.value.decode("utf-8")
dict_value = ast.literal_eval(string)
But by doing this I am not able to restrict the maximum messages per consume to two.