0

I am trying to extract message of kafka queue based on certain time ranges, say between Oct 2, 1 PM and Oct 2, 3 PM. How can I explicitly define this time range and just pull data off these time ranges.

bootstrap_servers = ['servername.com']
topicName = 'sales_topic'
consumer = KafkaConsumer(topicName, group_id='sales', bootstrap_servers=bootstrap_servers, auto_offset_reset='earliest', consumer_timeout_ms=20000)

I read about offsets_for_times but I am not sure how to use that. Any help around this would be appreciated.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • So, you read about the method, but have you tried it? What specific errors are you getting with it? – OneCricketeer Oct 04 '21 at 16:37
  • @OneCricketeer thanks for checking on this. It expected a dict but when I passed a dict to KafkaConsumer method it did not recognise it so wondering where am I going wrong. Given below is the error `KafkaConfigurationError: KafkaConfigurationError: Unrecognized configs: {'offsets_for_times'}` – Scott Nash Oct 04 '21 at 16:41
  • It's not a config option. It is a consumer instance method that returns values, which you then give to `consumer.seek()` method – OneCricketeer Oct 04 '21 at 18:31

0 Answers0