question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: How do I commit a partition?

See original GitHub issue

Using kafka-python-1.0.2.

If I have a topic with 10 partitions, how do I go about committing a particular partition, while looping through the various partitions and messages. I just cant seem find an example of this anywhere, in the docs or otherwise

From the docs, I want to use:

consumer.commit(offset=offsets)

Specifically, how do I create the partition and OffsetAndMetadata dictionary required for offsets (dict, optional) – {TopicPartition: OffsetAndMetadata}.

I was hoping the function call would just be something like:

consumer.commit(partition, offset), 

but this does not seem to be the case.

Thanks in advance.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
dpkpcommented, Apr 12, 2016

the metadata is really just an opaque string. You can also pass None. Nothing uses metadata internally, it is there as a way for you to store application-specific data if needed. But very few folks actually use that functionality, so beware if you go down that path.

0reactions
jeffwidmancommented, Mar 19, 2018

@gyoga99 this is an old issue, better to file a new ticket. Reading your description, there is also a decent chance that this is a misunderstanding of how kafka works, so you might want to also post this as a question on stackoverflow, as we generally try to reserve the issue tracker for bugs and feature requests.

Oops, looks like you posted https://github.com/dpkp/kafka-python/issues/1446 already

Read more comments on GitHub >

github_iconTop Results From Across the Web

kafka-python - How do I commit a partition? - Stack Overflow
Find a better way to do it. topic_partition = TopicPartition(TOPIC, message.partition) consumer.seek(topic_partition, offset_value) consumer.
Read more >
Kafka - When to commit? - Quarkus
It commits the offset, indicating that all the previous records from that partition have been processed. So, if a consumer stops and comes...
Read more >
Apache Kafka Offset Management - Learning Journal
The offset is a position within a partition for the next message to be sent to a consumer. ... The answer to the...
Read more >
Manually committing offsets in Kafka using .Net - Microsoft Q&A
I have a list of offsets with their corresponding partition and I need to commit them manually. To do so I am looping...
Read more >
How to read from a specific offset and partition with the Kafka ...
Start a console consumer to read from the second partition ... In the previous step, you consumed records from the first partition of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found