一個簡單的問題,我正在使用 php-rdkafka (https://github.com/arnaud-lb/php-rdkafka)冒險進入 Kafka。我瀏覽了文檔,但找不到生成現有主題的語法,除非語法 newTopic 將插入到我懷疑的現有主題中。我不斷拋出 Java 錯誤,而且我不擅長調試 Java 錯誤。我正在向那些一直在使用該框架的人尋求幫助,這是正確的語法嗎?請指教<?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貢獻1821條經驗 獲得超5個贊
根據與開發商的討論,
以下語法可用于創建新主題并將數據添加到以下/現有主題
$topic = $producer->newTopic("test"); /
- 1 回答
- 0 關注
- 139 瀏覽
添加回答
舉報
0/150
提交
取消