Good afternoon. Given: a kafka topic with more than 20 partitions and a huge message traffic and one consumer group. It is necessary each time connecting to a topic to reset all the lag available there (with data loss) on all partitions and read it from the most recent messages. Please tell me how to implement it. I use python + confluent-kafka. I need something like this pseudocode.
But it has two problems, I don't know how to get the list of partitions correctly and this code throws an error when trying to read from a topic.
def reset_offset_to_latest(consumer, partitions):
for p in partitions:
p.offset = confluent_kafka.OFFSET_END
print('assign', partitions)
consumer.assign(partitions)
Error:
cimpl.KafkaException: KafkaError{code=_STATE,val=-172,str="Failed to set assignment: Local: Erroneous state"}
Please help!