From 82e8b91b17aab5093ed83b2017f4158b365ec82e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 28 Oct 2020 11:47:58 +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/Kafka.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Kafka/Kafka.php b/Kafka/Kafka.php index a40b9fc0..f000c65d 100644 --- a/Kafka/Kafka.php +++ b/Kafka/Kafka.php @@ -82,9 +82,9 @@ class Kafka extends \Snowflake\Process\Process $objRdKafka = new \RdKafka\Consumer($config); $topic = $objRdKafka->newTopic($kafkaServer['topic'], $topic); $topic->consumeStart(0, RD_KAFKA_OFFSET_STORED); - while (true) { + Timer::tick($conf['interval'] ?? 1000, function () use ($topic) { $this->resolve($topic); - } + }); } @@ -94,7 +94,7 @@ class Kafka extends \Snowflake\Process\Process private function resolve(ConsumerTopic $topic) { try { - $message = $topic->consume(0, $conf['interval'] ?? 1000); + $message = $topic->consume(0, 0); if (empty($message)) { $this->application->debug('message null.'); return;