RdKafka\KafkaConsumer::commit

(PECL rdkafka >= 1.0.0, librdkafka >= 0.9)

RdKafka\KafkaConsumer::commitCommit offsets

Description

public RdKafka\KafkaConsumer::commit ([ mixed $message_or_offsets = NULL ] ) : void

Commit offsets synchronously, block until offsets are committed or the commit fails.

Note:

If a commit_cb callback is registered it will be called with commit details on a future call to consume.

Parameters

message_or_offsets
  • When NULL, commit offsets for the current assignment.
  • When a RdKafka\Message, commit offset for a single topic+partition based on the message.
  • When an array of RdKafka\TopicPartition, commit offsets for the provided list of partitions.

Errors/Exceptions

Examples

Example #1 RdKafka\KafkaConsumer::commit() example

<?php
// Commit offsets for the current assignment
$kafkaConsumer->commit();

// Commit offsets based on the message's topic, partition, and offset
$kafkaConsumer->commit($message);

// Commit offsets by providing a list of TopicPartition
$kafkaConsumer->commit([
    new 
RdKafka\TopicPartition($topic$partition$offset),
]);
?>

See Also