consumer manual commit not working
See original GitHub issueHi, when I run my consumer script I disable auto commits because in my use case there are some messages that need to be processed and if we got no errors then we can remove them from the queue hence the manual commit bit.
But when I manually commit the offset it is still there on next iteration of my script; of course if I re-enable auto-commit it’s gone…
this is my code:
from kafka import KafkaConsumer
from kafka.structs import OffsetAndMetadata
consumer = KafkaConsumer(bootstrap_servers='192.168.33.10:9092', consumer_timeout_ms=1000, enable_auto_commit=False)
consumer.subscribe(['my-topic', 'another-topic'])
for message in consumer:
print (message)
meta = consumer.partitions_for_topic(message.topic)
partition = consumer.assignment().pop()
offsets = OffsetAndMetadata(message.offset, meta)
options = {partition: offsets}
consumer.commit(offsets=options)
consumer.close()
any hints?
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Manual Commit Not Working As Expected · Issue #527 - GitHub
Let's say if my consumer (the only one in the consumer group) is currently consuming a message at offset 7, then some error...
Read more >Kafka manual commit problem : r/apachekafka - Reddit
Commit is a synchronous call but returns no errors. So we are not really sure at present why the commit does not take...
Read more >Spring kafka manual offset commit does not work as expected
When I forcefully crash (JVM) consumer application and start it again, the consumer does not fetch records from the last committed offset.
Read more >Apache Kafka Offset Management - Learning Journal
The solution to this particular problem is a manual commit. So, we can configure the auto-commit off and manually commit after processing the...
Read more >Consuming Messages - KafkaJS
When suppling a regular expression, the consumer will not match topics created ... When disabling autoCommit you can still manually commit message offsets, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is this still the right way to do manual commits?
assignment().pop() is wrong. That could give you any partition, but you want the particular messag e partition. Use TopicPartition(message.topic, message.partition)