Skip to content

docs: add manual offset commit example#3015

Merged
dpkp merged 1 commit into
dpkp:masterfrom
vividbaek:docs/add-manual-offset-commit-example
Jun 9, 2026
Merged

docs: add manual offset commit example#3015
dpkp merged 1 commit into
dpkp:masterfrom
vividbaek:docs/add-manual-offset-commit-example

Conversation

@vividbaek

Copy link
Copy Markdown
Contributor

Add a short KafkaConsumer example showing manual offset commits with TopicPartition and OffsetAndMetadata. Clarifies that you should commit the next offset to consume (e.g. commit message.offset + 1).

Quick example:

from kafka import KafkaConsumer, OffsetAndMetadata, TopicPartition
consumer = KafkaConsumer('my-topic', group_id='g', enable_auto_commit=False)
for msg in consumer:
process_message(msg)
tp = TopicPartition(msg.topic, msg.partition)
consumer.commit({tp: OffsetAndMetadata(msg.offset + 1, '', -1)})

@vividbaek vividbaek force-pushed the docs/add-manual-offset-commit-example branch 2 times, most recently from 4ea573e to 3de6e87 Compare May 31, 2026 07:32
@vividbaek vividbaek force-pushed the docs/add-manual-offset-commit-example branch from 3de6e87 to 5a3d717 Compare May 31, 2026 07:37
@dpkp

dpkp commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Thanks!

@dpkp dpkp merged commit 141a0ac into dpkp:master Jun 9, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants