0

I want to check if my topic is empty after changing a retention.ms to 100ms. I try to consume from my topic like this :

    consumer_kafka = KafkaConsumer(topic, bootstrap_servers=bootstrap_servers, auto_offset_reset='latest',
                               consumer_timeout_ms=10000)
    for message in consumer_kafka:
      if message is None:
        return True
      else:
        return False

If return True (topic purged) so i send my json files. But this method return None. Can anyone help me ?.

LilyAZ
  • 133
  • 3
  • 10
  • It is not clear to me what you are trying to achieve. To where are you send JSON file and how? How did you change the retention time? How can the method return "None" if the code shows only "true" and "false" as return? – Michael Heil Sep 29 '20 at 10:07
  • the goal of my project is to purge the kafka topic and return new json files, that's why I change the retention time. For this I have to first check if there is no data in the topic and then send the files – LilyAZ Sep 29 '20 at 10:13
  • Still not clear to me, sorry. Maybe try to answer the questions of my first comment. If not, maybe someone else has an idea... – Michael Heil Sep 29 '20 at 10:18
  • sorry, maybe I misexplained what I want to do. :( – LilyAZ Sep 29 '20 at 10:25

0 Answers0