RdKafka\Conf::setDrMsgCb

(PECL rdkafka >= 1.0.0)

RdKafka\Conf::setDrMsgCbSet delivery report callback

Description

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

Set delivery report callback. The delivery report callback will be called once for each message accepted by RdKafka\ProducerTopic::produce() with err set to indicate the result of the produce request.

The callback is called when a message is succesfully produced or if librdkafka encountered a permanent failure, or the retry counter for temporary errors has been exhausted.

An application must call RdKafka::poll() at regular intervals to serve queued delivery report callbacks.

Parameters

callback (callable)

A callable with the following signature:

<?php
/**
 * @param RdKafka\Kafka $kafka
 * @param RdKafka\Message $message
 */
function (RdKafka\Kafka $kafkaRdKafka\Message $message);

Return Values

Returns no value.

Examples

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

<?php
$conf
->setDrMsgCb(function ($kafka$message) {
    if (
$message->err) {
        
// message permanently failed to be delivered
    
} else {
        
// message successfully delivered
    
}
});
?>