PHP 与 Kafka - rdkafka [英] PHP with Kafka - rdkafka
问题描述
我正在处理kafka和php,我是初学者,kafka已经在服务器上正确设置,
Iam dealing with kafka and php, Im beginner the kafka has been set upped correctly on the server,
现在在本地我已经安装:xamp/php 上的 librdkafka.dll和 xamp/php/ext 上的 php_rdkafka.dll
now am on local I have installed: librdkafka.dll on xamp/php and php_rdkafka.dll on xamp/php/ext
我在 php.ini 添加了这个:
and i added this on php.ini:
extension=php_rdkafka.dll
extension=php_rdkafka.dll
然后,我创建了一个包含以下代码的 php 页面:
then, i have created a php page contains this code:
$topic_name = '???';
$conf = new RdKafka\Conf();
$conf->set('metadata.broker.list', $broker_list);
$conf->set('enable.idempotence', 'true');
$conf->set('group.id', $topic_name);
$conf->set('sasl.username', "???");
$conf->set('sasl.mechanism', "PLAIN");
$conf->set('sasl.password', "???");
$conf->set('log_level', (string) LOG_DEBUG);
$conf->set('debug', 'all');
$producer = new RdKafka\Producer($conf);
$producer->addBrokers($broker_list);
$topic = $producer->newTopic($topic_name);
$topic->produce(RD_KAFKA_PARTITION_UA, 0, "Message Test");
$producer->poll(0);
$result = $producer->flush(10000);```
but nothing returns on stream, could anyone help me?
推荐答案
您是否正在尝试连接到融合云?
Are you trying to connect to confluent cloud?
我会将您的安全协议添加到您的 conf 中,正如您指出的 sasl.例如 $conf->set('security.protocol','sasl_ssl');
I would add to your conf your security protocol, as you indicate sasl. eg $conf->set('security.protocol','sasl_ssl');
我认为您不需要在生产者中指明代理,因为您已经在配置中这样做了.我假设您的经纪人列表是一个包含主机和端口号的 csv 格式文件?
I would think you would not need to indicate the brokers in the producer, as you have already done this in the config. I am presuming your broker list is a csv formatted file that include host and port number?
这篇关于PHP 与 Kafka - rdkafka的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!