From 6787d7c2ae780f08d92be5da217fac59de1142ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 24 Mar 2021 19:23:09 +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 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Kafka/Producer.php b/Kafka/Producer.php index 0774e1b3..f20f5695 100644 --- a/Kafka/Producer.php +++ b/Kafka/Producer.php @@ -92,9 +92,7 @@ class Producer extends Component * @param string $topic * @param array $params * @param string|null $groupId - * @throws NotFindClassException - * @throws ReflectionException - * @throws ConfigException + * @throws Exception */ public function dispatch(string $topic, array $params = [], string $groupId = null) { @@ -102,13 +100,16 @@ class Producer extends Component if (empty($consumers) || !is_array($consumers)) { return; } - + if (!isset($consumers['brokers'])) { + throw new Exception('You need set brokers config.'); + } if (!empty($groupId)) { $consumers['groupId'] = $groupId; } else if (!isset($consumers['groupId'])) { $consumers['groupId'] = $topic . ':' . Snowflake::localhost(); } $this->setGroupId($groupId)->setTopic($topic) + ->setBrokers($consumers['brokers']) ->delivery(swoole_serialize($params)); }