Closed abdelghanimeliani closed 1 month ago
1-2 mins is not normal even if you subscribe to a new topic every time. Can you try with same topic by subscribing only once?
hey @pranavrth, the issue arose because when auto.offset.reset
is set to latest
, the consumer cannot fetch events produced before its subscription and waits for the producer to generate a new event. By setting 'auto.offset.reset' to earliest
, the consumer can now access the old events, but this results in retrieving the oldest event in the topic, which is not suitable for my use case. I will close this issue for now as it is not a confluent-kafka-python problem and will continue addressing it in the discussion at this link : https://github.com/confluentinc/confluent-kafka-python/discussions/1752.
Description
I am writing a Flask API to retrieve data from Apache Kafka topics. The consumer subscribes to a different topic each time according to the API path and uses the confluent_kafka.Consumer.consume method to fetch a given number of events each time. Here is the consumer configuration I am using:
The code to consume events from the given topic is as follows:
the
assignment_callback
and themessages_parser
are other methods that i built . The problem is that it takes a long time (1-2 minutes) to return the answer. Is this normal behavior, or is there something wrong with the configuration or usage? additional infomration: I am using kafka as a docker container for an experimental environmentHow to reproduce
Checklist
Please provide the following information:
[x]
confluent_kafka.version()
= ('2.3.0', 33751040)confluent_kafka.libversion()
= ('2.3.0', 33751295)[x] Apache Kafka broker version: 3.7.0
[x] Client configuration: given in the description
[x] Operating system: ubuntu 22.04 but im using kakfa in a docker image
[x] Provide client logs (with
'debug': '..'
as necessary): nothing abnormal[x] Provide broker log excerpts :same