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.

from-beginning equivalent when using the client

See original GitHub issue

The command line tool kafka-console-consumer.sh has the option --from-beginning. What is the client’s equivalent?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
matthewfranglencommented, Oct 27, 2015

You can create a KafkaConsumer with the auto_offset_reset='smallest' keyword argument:

from kafka import KafkaConsumer

consumer = KafkaConsumer(
    'test',
    group_id='example',
    bootstrap_servers=['localhost:9092'],
    auto_offset_reset='smallest'
)

consumer.offsets()
{'commit': {('test', 0): None},
 'fetch': {('test', 0): 0},
 'highwater': {('test', 0): None},
 'task_done': {('test', 0): None}}
1reaction
jmess4commented, Jul 2, 2021

auto_offset_reset only kicks in if the consumer does not have a valid offset for a given partition. If you don’t need a group you can set group_id=None to get the behavior you want. Otherwise you’ll need to manually assign partitions and then seek to beginning.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set group name when consuming messages in kafka ...
The simplest solution is: bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic nil_RF2_P2 --from-beginning --consumer-property ...
Read more >
How to read from a specific offset and partition with the Kafka ...
In this tutorial, learn how to read from a specific offset and partition with the commandline consumer using Confluent, with step-by-step instructions and ......
Read more >
KafkaConsumer (kafka 2.5.0 API)
A client that consumes records from a Kafka cluster. This client transparently handles the failure of Kafka brokers, and transparently adapts as topic ......
Read more >
BA Chapter 14 Flashcards - Quizlet
An individual who has been certified by the state in which he or she practices and has the right to express, officially, an...
Read more >
Consumer - KafkaJS
The following example assumes that you are using the local Kafka configuration ... fromBeginning: true }) await consumer.run({ // eachBatch: async ({ batch...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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