From b943a7af8aa43430b0417c36f1c658b7f4940659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 28 Oct 2020 16:10:23 +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 | 4 +--- System/Abstracts/BaseApplication.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Kafka/Producer.php b/Kafka/Producer.php index eb6de6f0..c8d49f0f 100644 --- a/Kafka/Producer.php +++ b/Kafka/Producer.php @@ -108,9 +108,7 @@ class Producer extends Component $rk = new \RdKafka\Producer(); $topic = $rk->newTopic($this->_topic, $this->topicConf); $topic->produce(RD_KAFKA_PARTITION_UA, 0, $message, $key); - if ($rk->getOutQLen() > 0) { - $rk->poll($timeout); - } + $rk->poll($timeout); $rk->flush($timeout); } } diff --git a/System/Abstracts/BaseApplication.php b/System/Abstracts/BaseApplication.php index 46e0161f..8a9deb73 100644 --- a/System/Abstracts/BaseApplication.php +++ b/System/Abstracts/BaseApplication.php @@ -242,6 +242,16 @@ abstract class BaseApplication extends Service } + /** + * @return Producer + * @throws ComponentException + */ + public function getKafka() + { + return $this->get('kafka'); + } + + /** * @return \Redis|Redis * @throws ComponentException