I have a confluent-kafka consumer which will be running once in a day. while its running i just wants to get one last message from the topic. I have below code, but is not fetching the last message, just reading the messages other than the last message. My confluent-kafka consumer code looks like:
cfg = {
'bootstrap.servers': host,
'group.id': groupName,
'api.version.request': False,
'enable.auto.commit': True,
'session.timeout.ms': 6000,
'default.topic.config': {'auto.offset.reset': 'largest'},
'security.protocol': 'SSL',
'ssl.key.password': 'pswd',
'ssl.ca.location': certPath,
}
C = Consumer(cfg)
C.assign([TopicPartition(topicName, 1)])
C.subscribe([topicName])
msgList=[]
while True:
msg = C.poll(6.0)
if msg:
jsonmsg= json.loads(msg.value())
if jsonmsg[expectedValue]==eventId:
msgList.append(eventId)
break
where eventId is the value present on the last published message. Do I need to include any parameter or Am I missing something in configs ? Any help would be appreciated.