I'm trying to write a kafka consumer in python using Confluent Kafka. I can get all new messages but I don't get any old messages if I kill and restart my consumer
def confluent_kafka_consumer(app):
with app.app_context():
import config
app.logger.info('Running Confluent Kafka consumer')
consumer_config = {
'bootstrap.servers': F'{config.Config.KAFKA_BROKER_URL}:{config.Config.KAFKA_BROKER_PORT}',
'group.id': 'myGroupId',
'auto.offset.reset': 'earliest',
'enable.auto.commit': 'false',
'max.poll.interval.ms': '86400000'
}
try:
consumer = Consumer(consumer_config)
consumer.subscribe(['updates'])
while True:
# read single message at a time
msg = consumer.poll(0)
if msg is None:
gevent.sleep(config.DevelopmentConfig.KAFKA_CONSUMER_THREAD_SLEEP_TIME)
continue
if msg.error():
print("Error reading message : {}".format(msg.error()))
continue
# You can parse message and save to data base here
callstr = msg.value().decode('utf-8')
print(callstr)
except Exception as ex:
print("Kafka Exception : {}", ex)
finally:
print("closing consumer")
consumer.close()
I tried setting groupId to something different, restarting the producer, zookeper...