1

My confluent-kafka-python - version 1.7.0 producer code is as below

from confluent_kafka import KafkaError, KafkaException
def publish_data():

   try:

        producer.produce(
            topic=topic,
            value={"produced_epoch": produced_epoch },
        )
        producer.flush()
    except (KafkaError, RuntimeError, KafkaException, Exception) as e:
        logging.error(f'Error publishing to kafka : {e}')
        return False
    return True

While producing the code I am getting the below error in Kafka broker

%5|1634047381.445|REQTMOUT|rdkafka#producer-1| [thrd:ssl://kafka-kafka-2.kafka-kafka-brokers.kafka.svc:9093/2]: ssl://kafka-kafka-2.kafka-kafka-brokers.kafka.svc:9093/2: Timed out ProduceRequest in flight (after 60844ms, timeout #0) 
%5|1634047381.445|REQTMOUT|rdkafka#producer-1| [thrd:ssl://kafka-kafka-2.kafka-kafka-brokers.kafka.svc:9093/2]: ssl://kafka-kafka-2.kafka-kafka-brokers.kafka.svc:9093/2: Timed out ProduceRequest in flight (after 60837ms, timeout #1) 
%5|1634047381.445|REQTMOUT|rdkafka#producer-1| [thrd:ssl://kafka-kafka-2.kafka-kafka-brokers.kafka.svc:9093/2]: ssl://kafka-kafka-2.kafka-kafka-brokers.kafka.svc:9093/2: Timed out ProduceRequest in flight (after 60816ms, timeout #2) 
%5|1634047381.445|REQTMOUT|rdkafka#producer-1| [thrd:ssl://kafka-kafka-2.kafka-kafka-brokers.kafka.svc:9093/2]: ssl://kafka-kafka-2.kafka-kafka-brokers.kafka.svc:9093/2: Timed out ProduceRequest in flight (after 60809ms, timeout #3) 
%5|1634047381.445|REQTMOUT|rdkafka#producer-1| [thrd:ssl://kafka-kafka-2.kafka-kafka-brokers.kafka.svc:9093/2]: ssl://kafka-kafka-2.kafka-kafka-brokers.kafka.svc:9093/2: Timed out ProduceRequest in flight (after 60788ms, timeout #4) 
%4|1634047381.445|REQTMOUT|rdkafka#producer-1| [thrd:ssl://kafka-kafka-2.kafka-kafka-brokers.kafka.svc:9093/2]: ssl://kafka-kafka-2.kafka-kafka-brokers.kafka.svc:9093/2: Timed out 31 in-flight, 0 retry-queued, 0 out-queue, 0 partially-sent requests 
%3|1634047381.445|FAIL|rdkafka#producer-1| [thrd:ssl://kafka-kafka-2.kafka-kafka-brokers.kafka.svc:9093/2]: ssl://kafka-kafka-2.kafka-kafka-brokers.kafka.svc:9093/2: 31 request(s) timed out: disconnect (after 108069ms in state UP)

I want to catch the REQTMOUT error and return False when error. But unable to do the same. Can anyone help me with it.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Zaks
  • 668
  • 1
  • 8
  • 30

0 Answers0