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.

How to subscribe/assign a consumer based on a timestamp instead of offset?

See original GitHub issue

Hiya!

I’m looking into building in timestamp based subscription support to KafkaSSE and Wikimedia EventStreams. Using the latest node-rdkafka and a Kafka 1.0 cluster, I can get the message timestamps from the consumer no problem. But, if I’d like to use one of these to assign the consumer to a particular position in the partition, how do I do so? Ideally, I’d be able to just provide the timestamp in the assignment I give to consumer assign(), e.g.

kafkaConsumer.assign([{
    topic: 'my-topic',
    partition: 0,
    timestamp: 1515618893265,
}]

I understand that librdkafka doesn’t work this way (right?). It seems with librdkafka, you must use first make a request for the offset associated with a timestamp, and then use that in your consumer assignment. I could use this if it was supported in node-rdkafka.

Is there a way to do this now that I am missing?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:31 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
ottomatacommented, Jun 14, 2018

@webmakersteve thanks again so much for this. It enabled me to implement and deploy: https://wikitech.wikimedia.org/wiki/EventStreams#Timestamp_Historical_Consumption See also https://stream.wikimedia.org/?doc#!/Streams/get_v2_stream_streams

Now folks can publicly consume Wikimedia events (like realtime article edit metadata) and provide a historical timestamp from which they want to start consuming. Very cool.

3reactions
webmakerstevecommented, Apr 25, 2018

Will add one to the README

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get kafka offset data, specified on timestamp
To find the offsets that correspond to a timestamp, you need to use the offsetsForTimes() method. For example, this will print the offsets...
Read more >
Solved: How can i consume kafka offsets based on timestamp...
Solved: How can i consume kafka offsets based on timestamp? ... Kafka when the job restarts at the next batch cycle: consumer.assign([tp]).
Read more >
Java Consumer Seek and Assign Tutorial | Learn Kafka with ...
Remove the subscription to the topic. Use consumer assign() and seek() APIs. The code with these changes is shown in the snippet below....
Read more >
Kafka Consumer | Confluent Documentation
An Apache Kafka consumer group is a set of consumers which cooperate to consume data ... the position is set according to a...
Read more >
Retrieve Kafka Messages (Records) via Timestamp - Kontext
In most scenarios, Kafka consumers read records in partitions via offset - an integer to indicate the position of next record to read...
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