Is there any API using which kafka client can force the metadata refresh for stream application?

Producer can fail to produce the event due to out of the date partition or topic metadata information. I was reading about Parameter in KafkaProducer/KafkaConsumer. Keeping property as low as possible will allow more frequent refresh of metadata which means more chances to have latest information of partition/topic.

But just wanted to check if there is another better way to handle this. Is it possible to catch the org.apache.kafka.common.errors.NotLeaderOrFollowerException exception and call some API on demand to enforce the refresh of metadata.