This commit is contained in:
2020-10-28 16:46:03 +08:00
parent d7097e46e5
commit 09a82ff676
+5
View File
@@ -102,7 +102,12 @@ class Producer extends Component
$this->error(sprintf("Kafka error: %s (reason: %s)", rd_kafka_err2str($err), $reason)); $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]); $rk = Snowflake::createObject(\RdKafka\Producer::class, [$this->conf]);
if ($rk->getOutQLen() > 0) {
$rk->flush($timeout);
}
$topic = $rk->newTopic($this->_topic, $this->topicConf); $topic = $rk->newTopic($this->_topic, $this->topicConf);
$topic->produce(RD_KAFKA_PARTITION_UA, 0, $message, $key); $topic->produce(RD_KAFKA_PARTITION_UA, 0, $message, $key);
$rk->poll(0); $rk->poll(0);