一个简单的问题,我正在使用 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条经验 获得超4个赞
根据与开发商的讨论,
以下语法可用于创建新主题并将数据添加到以下/现有主题
$topic = $producer->newTopic("test"); /
- 1 回答
- 0 关注
- 110 浏览
添加回答
举报
0/150
提交
取消