These are chat archives for arnaud-lb/php-rdkafka

7th
Nov 2018
jg111010
@jg101110
Nov 07 2018 03:21
How to solve the problem that Kafka can't connect in the process of sending information, which leads to process blocking? Has anyone ever encountered such a problem?
karavzeka
@karavzeka
Nov 07 2018 06:06
@jg101110 do you mean your script stuck when producer try to send message and get an error?
Try to add callbacks before producing and pass not 0 timeout to poll(). Something like that:
$conf->setErrorCb(function ($kafka, $err, $reason) {
    throw new Exception($reason, $err);
});
$conf->setDrMsgCb(function (Producer $kafka, Message $message) {
    if ($message->err) {
        throw new Exception($message->errstr(), $message->err);
    }
});

$producer = new Producer($conf);
$producer->addBrokers($brokerList);
$topic = $this->producer->newTopic($topicName);
$topic->produce(RD_KAFKA_PARTITION_UA, 0, $message, $key);
$producer->poll(2000);
jg111010
@jg101110
Nov 07 2018 06:27
@karavzeka I can't find poll() method.I use PHP .