I am writing a Python application which connects to a Kafka queue and sends a message to the queue. I have the following working code:
def send_msg(self, topic, msg):
self.producer = KafkaProducer(bootstrap_servers=['XX.XXX.XX.XXX:XXXX'])
future = self.producer.send(topic, msg)
self.producer.flush()
I want to add the standard try-catch expressions in this code so that I can catch any kind of exceptions that I might face. What are the various exceptions like connection, timeout, NoBrokersAvailable and how should I properly handle them?
Thanks in advance!