使用php rdkafka發送消息需要以下步驟:
pecl install rdkafka
<?php
$conf = new RdKafka\Conf();
$conf->set('metadata.broker.list', 'broker1:9092,broker2:9092');
$producer = new RdKafka\Producer($conf);
$topic = $producer->newTopic("test-topic");
$topic->produce(RD_KAFKA_PARTITION_UA, 0, 'Hello, Kafka!');
$producer->poll(0);
$producer->flush(10000); //10秒超時
以上就是使用php rdkafka發送消息的基本步驟。可以根據需要對發送消息的參數進行定制化配置。