RdKafka\Conf::setErrorCb

(PECL rdkafka >= 0.9.1)

RdKafka\Conf::setErrorCbSet error callback

Description

public RdKafka\Conf::setErrorCb ( callable $callback ) : void

Set error callback. The error callback is used by librdkafka to signal critical errors back to the application.

Parameters

callback (callable)

A callable with one of the following signatures.

When used with a RdKafka\KafkaConsumer instance:

<?php
function (RdKafka\KafkaConsumer $kafkaint $errstring $reason);

When used with a RdKafka\Producer instance:

<?php
function (RdKafka\Producer $kafkaint $errstring $reason);

Return Values

Returns no value.

Examples

Example #1 RdKafka\Conf::setErrorCb() example

<?php
$conf
->setErrorCb(function ($kafka$err$reason) {
    
printf("Kafka error: %s (reason: %s)\n"rd_kafka_err2str($err), $reason);
});
?>