改名
This commit is contained in:
+3
-7
@@ -49,20 +49,16 @@ class Kafka extends \Snowflake\Process\Process
|
|||||||
/**
|
/**
|
||||||
* @param Process $process
|
* @param Process $process
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
* @throws \RdKafka\Exception
|
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function onHandler(Process $process)
|
public function onHandler(Process $process)
|
||||||
{
|
{
|
||||||
$this->channelListener();
|
$this->channelListener();
|
||||||
[$config, $conf] = $this->kafkaConfig();
|
[$config, $conf] = $this->kafkaConfig();
|
||||||
$objRdKafka = new \RdKafka\Consumer($config);
|
$objRdKafka = new KafkaConsumer($config);
|
||||||
$objRdKafka->addBrokers("localhost:9092");
|
$objRdKafka->subscribe(['test']);
|
||||||
|
|
||||||
$consumer = $objRdKafka->newTopic('test');
|
|
||||||
$consumer->consumeStart(0, RD_KAFKA_OFFSET_END);
|
|
||||||
while (true) {
|
while (true) {
|
||||||
$message = $consumer->consume(0, $conf['metadataRefreshIntervalMs'] ?? 1000);
|
$message = $objRdKafka->consume($conf['metadataRefreshIntervalMs'] ?? 1000);
|
||||||
if (empty($message)) {
|
if (empty($message)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user