You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Daniel Wikström <Da...@tradedoubler.com> on 2016/10/26 09:39:40 UTC
In-Reply-To=%3CCALsq4vKokx2_haKCwXHdoHrsVwn8UoBETCco6o1dwyFDoed1aw%40mail.gmail.com%3E&Subject=TimeoutException%3A%20failed%20to%20update%20metadata%20after
The KafkaProducer have a method partitionsFor() that fetches the metadata. So something like this can be used to force load the metadata with max.block.ms=0
while(!gotMetadata) {
try {
producer.partitionsFor(topic);
gotMetadata=true;
} catch (TimeoutException e) {
logger.info(String.format("KafkaProducer for topic %s is waiting for metadata...", topic));
try {
Thread.sleep(100);
} catch (InterruptedException ignored) {
}
}
}