Skip to content

message.commit() For commiting specific message.  #1203

Closed
@aliowka

Description

@aliowka

When I want to commit only one message (a specific offset to a partition the message came from), I'm doing this:

from kafka import KafkaConsumer, OffsetAndMetadata

consumer = KafkaConsumer(TOPIC, enable_auto_commit=False)
message = consumer.poll(1000, max_records=1)
if message:
    offsets = {list(message.keys())[0]:
                OffsetAndMetadata(list(message.values())[0][0].offset + 1, '')}
    consumer.commit(offsets)

I wonder if this makes sense and if there is a simpler way of getting the offset {TopicPartition: OffsetAndMetadata} for a message?

Have you considered to add something like message.commit() method?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions