Closed Nabil-Miri closed 1 week ago
Producers internally tries to reconnect periodically if the connection is not established. You don't need to do that on your own.
So no need for the whole checkAndReconnect() function, right?
@pranavrth BTW, I noticed in some places, reconnection is tested using list_topics like in the test_Producer.py
try:
p.list_topics(timeout=0.2)
except KafkaException as e:
assert e.args[0].code() in (KafkaError._TIMED_OUT, KafkaError._TRANSPORT)
So what is the difference if I used the list_topics and the periodic reconnection of the Producer.
Producer internally tries to connect to the brokers periodically. You will achieve the same thing if you try create the producer again and again with the same bootstrap-servers. Creating producer instance is a costly operation and will be an overhead for your application.
Noted. Thanks a lot for your reply.
Description
Hello, I have a code with a producer. I want to know if there is a method to know if there is any error or no connection in the producer and if not, there reconnect or create the producer again.
Code:
How to reproduce
Currently the poll(0) does not help in doing so. What could be a solution? Thanks.
Checklist
Please provide the following information:
confluent_kafka.version()
andconfluent_kafka.libversion()
): 2.5.0{...}
'debug': '..'
as necessary)