一個(gè)簡單的問題,我正在使用 php-rdkafka (https://github.com/arnaud-lb/php-rdkafka)冒險(xiǎn)進(jìn)入 Kafka。我瀏覽了文檔,但找不到生成現(xiàn)有主題的語法,除非語法 newTopic 將插入到我懷疑的現(xiàn)有主題中。我不斷拋出 Java 錯(cuò)誤,而且我不擅長調(diào)試 Java 錯(cuò)誤。我正在向那些一直在使用該框架的人尋求幫助,這是正確的語法嗎?請指教<?php$conf = new RdKafka\Conf();$conf->set('metadata.broker.list', 'localhost:9092');//If you need to produce exactly once and want to keep the original produce order, uncomment the line below//$conf->set('enable.idempotence', 'true');$producer = new RdKafka\Producer($conf);$topic = $producer->newTopic("test"); // Is this a correct syntax to consume existing topic?for ($i = 0; $i < 10; $i++) { $topic->produce(RD_KAFKA_PARTITION_UA, 0, "Message $i"); $producer->poll(0);}for ($flushRetries = 0; $flushRetries < 10; $flushRetries++) { $result = $producer->flush(10000); if (RD_KAFKA_RESP_ERR_NO_ERROR === $result) { break; }}if (RD_KAFKA_RESP_ERR_NO_ERROR !== $result) { throw new \RuntimeException('Was unable to flush, messages might be lost!');}
1 回答

收到一只叮咚
TA貢獻(xiàn)1821條經(jīng)驗(yàn) 獲得超5個(gè)贊
根據(jù)與開發(fā)商的討論,
以下語法可用于創(chuàng)建新主題并將數(shù)據(jù)添加到以下/現(xiàn)有主題
$topic = $producer->newTopic("test"); /
- 1 回答
- 0 關(guān)注
- 136 瀏覽
添加回答
舉報(bào)
0/150
提交
取消