I have two consumer groups for one kafka topic I want setup such a method that if one consumer group gets down then 2nd comsumer group starts consuming from the offset left by the 1st one to avoid duplication
I am exploring ideas that are industry level
This isn't possible, nor necessary. Offsets are unique per consumer group.
You'd have to explicitly seek and commit the offsets for the second group, or just not use Kafka for group management altogether, and instead store and query from an external system.
Restarting any instance of one group would pickup from the last committed position. This would cause at-least once processing. You'd additionally require transactions to handle exactly once processing.