This commit is contained in:
2020-10-28 16:10:23 +08:00
parent f05e459be6
commit b943a7af8a
2 changed files with 11 additions and 3 deletions
+1 -3
View File
@@ -108,9 +108,7 @@ class Producer extends Component
$rk = new \RdKafka\Producer(); $rk = new \RdKafka\Producer();
$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);
if ($rk->getOutQLen() > 0) { $rk->poll($timeout);
$rk->poll($timeout);
}
$rk->flush($timeout); $rk->flush($timeout);
} }
} }
+10
View File
@@ -242,6 +242,16 @@ abstract class BaseApplication extends Service
} }
/**
* @return Producer
* @throws ComponentException
*/
public function getKafka()
{
return $this->get('kafka');
}
/** /**
* @return \Redis|Redis * @return \Redis|Redis
* @throws ComponentException * @throws ComponentException