Skip to content

Expose rd_kafka_position and rd_kafka_committed #50

@lucabrunox

Description

@lucabrunox

librdkafka has two methods that are very useful for comitting offsets manually when consuming.

rd_kafka_position: https://github.com/edenhill/librdkafka/blob/dca8b2ee91076f2ca72f00abb4d18102a4b7e19a/src/rdkafka.h#L2035

and

rd_kafka_committed:
https://github.com/edenhill/librdkafka/blob/dca8b2ee91076f2ca72f00abb4d18102a4b7e19a/src/rdkafka.h#L2016

That is, instead of relying on commit() without arguments which automatically commits the fetched messages, it's possible to manually provide the offsets to be committed.

The use case is when fetched messages are consumed partially. That is, if 10 messages are fetched but only the first 5 have been processed for one reason or another, it's wanted to only commit 5 messages, hence pass custom information to commit().
However, currently in php-rdkafka there's no way to know such offsets, if I'm not wrong.

rd_kafka_position is certainly the most interesting for such a use case, but given rd_kafka_committed has a similar API, it shouldn't be hard to also expose it.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions