From aebfda74c63272965288055ed4a65b0d279c5897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 30 Oct 2020 11:24:22 +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, 3 insertions(+), 2 deletions(-) diff --git a/Kafka/Producer.php b/Kafka/Producer.php index 994954c0..11af0bae 100644 --- a/Kafka/Producer.php +++ b/Kafka/Producer.php @@ -96,8 +96,9 @@ class Producer extends Component $event = Snowflake::app()->getEvent(); $event->on(Event::EVENT_AFTER_REQUEST, [$this, 'flush']); - /** @var \RdKafka\Producer $rk */ - $this->producer = Snowflake::createObject(\RdKafka\Producer::class, [$this->conf]); + if (!$this->producer) { + $this->producer = Snowflake::createObject(\RdKafka\Producer::class, [$this->conf]); + } $topic = $this->producer->newTopic($this->_topic, $this->topicConf); $topic->produce(RD_KAFKA_PARTITION_UA, 0, $message, $key); $this->producer->poll(0);