(PECL rdkafka >= 4.0.0, librdkafka >= 0.9.1)
RdKafka\KafkaConsumer::getOffsetPositions — Retrieve the current offsets for topics / partitions
$topics
) : arrayThe offset field of each requested partition will be set to the offset of the last consumed message + 1, or RD_KAFKA_OFFSET_INVALID in case there was no previous message.
topics
(array)Array of RdKafka\TopicPartition.
Returns an array of RdKafka\TopicPartition with their offsets
Example #1 RdKafka\KafkaConsumer::getOffsetPositions() example
<?php
$conf = new RdKafka\Conf();
$conf->set("group.id", "myGroupID");
$kafkaConsumer = new RdKafka\KafkaConsumer($conf);
$topicPartition = new TopicPartition('myTopic', 0);
$timeoutMs = 10000000;
$topicPartitionsWithOffsets = $kafkaConsumer->getOffsetPositions([$topicPartition]));
?>