2

what command to use if I want to consume messages between two specific dates like 20 Feb 00:00:00 and 22 Feb 00:00:00 from a Kafka topic ?
All I know is that there is consumer groups command in which we can give "--to-datetime" ,"--by-duration" etc.

bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092
--group test-group --reset-offsets --all-topics --to-datetime 2021-02-20T00:00:00.000

But how can I stop that consumer group when it reaches a particular datetime (2021-02-22T00:00:00.000)?

Thanks.

Nan-7
  • 71
  • 1
  • 8
  • 1
    Does this answer your question? [How to consume messages between two timestamps using Kafka Console Consumer](https://stackoverflow.com/questions/60882882/how-to-consume-messages-between-two-timestamps-using-kafka-console-consumer) – Madhu Bhat Feb 22 '21 at 14:03

1 Answers1

2

You can do this with kafkacat

kafkacat -b mybroker -C -t mytopic -o s@1568276612443 -o e@1568276617901

Where the two timestamps are specified as milliseconds since the Unix epoch

Robin Moffatt
  • 30,382
  • 3
  • 65
  • 92
  • Hi Robin, thanks for this but I don't have kafkacat on my servers and sadly can't download it also , can you help with some other utility that gets shipped with confluent platform? – Nan-7 Feb 23 '21 at 16:32
  • Is there any equivalent command for kafkacat in windows? – PAA Mar 06 '21 at 13:05
  • @Pra_A you can run Kafkacat under Docker on Windows – Robin Moffatt Mar 07 '21 at 16:14