我的confluent-kafka-python
- 版本 1.7.0 生产者代码如下
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
在生成代码时,我在 Kafka 代理中收到以下错误
%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)
我想捕获 REQTMOUT 错误并在错误时返回 False。但无法做同样的事情。任何人都可以帮助我。