From 09a82ff676cadc959b6347e48dd8b51749492c2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 28 Oct 2020 16:46:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Kafka/Producer.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Kafka/Producer.php b/Kafka/Producer.php index aa894014..18444569 100644 --- a/Kafka/Producer.php +++ b/Kafka/Producer.php @@ -102,7 +102,12 @@ class Producer extends Component $this->error(sprintf("Kafka error: %s (reason: %s)", rd_kafka_err2str($err), $reason)); }); + /** @var \RdKafka\Producer $rk */ $rk = Snowflake::createObject(\RdKafka\Producer::class, [$this->conf]); + if ($rk->getOutQLen() > 0) { + $rk->flush($timeout); + } + $topic = $rk->newTopic($this->_topic, $this->topicConf); $topic->produce(RD_KAFKA_PARTITION_UA, 0, $message, $key); $rk->poll(0);