Closed nikolamilojica closed 1 year ago
What behaviour do you expect? async for msg in consumer
just waits for new message to arrive.
What behaviour do you expect?
async for msg in consumer
just waits for new message to arrive.
Hello, I was assuming once the messages are consumed by consumer object, interpreter should move to finally block.
Usually, kafka is used in stream processing approach, so the iterator you get from async for
is infinite until the consumer/event loop is stopped.
If you want to do some kind of batch processing, you can use getmany
with a timeout that will return after X milliseconds if no messages are consumed
Usually, kafka is used in stream processing approach, so the iterator you get from
async for
is infinite until the consumer/event loop is stopped.If you want to do some kind of batch processing, you can use
getmany
with a timeout that will return after X milliseconds if no messages are consumed
Thank you for this clarification. I do not want to listen topic forever, I just want to go through messages. Once I test this, I will close the question.
Hi there!
Could you help me understand why the following code is hanging and not finishing execution? I am using this docker-compose configuration to spin up local Kafka:
Once Kafka is up, I create a topic and fill it with a few short messages using the following Docker commands:
After filling the
illuminate
topic with the short and simple messages:first
,second
, andthird
, the following code hangs (which is essentially the most basic case for the AIOKafkaConsumer class):Output with KeyboardInterrupt after 3 hours of "hanging":
Is my setup flawed? Any help is more then appreciated. Thanks in advance.