@Sunil The else branch will be executed if `metadata.fetch().partitionsForTopic(topic)` returns non NULL value. I assume that when Kafka is unreachable, it will return NULL. `waitOnMetadata()` then returns; we never enter the else branch when Kafka is unreachable.
@Everyone: Is this explanation correct? On Fri, Mar 20, 2015 at 3:56 PM, sunil kalva <sambarc...@gmail.com> wrote: > @Samuel > My point was > The else branch of the code will be executed when metadata is not > available, and metadata is not available when kafka cluster is not rachable. > > please correct me if i am wrong.. > > On Fri, Mar 20, 2015 at 3:43 PM, Samuel Chase <samebch...@gmail.com> wrote: > >> @Sunil >> >> On Fri, Mar 20, 2015 at 3:36 PM, sunil kalva <sambarc...@gmail.com> wrote: >> > I think KafkaProducer.send method blocks until it fetches partition >> > metadata for configured time using "metadata.fetch.timeout.ms", once >> time >> > out it throws TimeoutException. You might be experiencing >> TimeoutException ? >> >> My co-worker pointed out that over here: >> >> https://github.com/apache/kafka/blob/0.8.2/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java#L368 >> >> waitOnMetadata just returns. The else branch of the code is not >> executed when Kafka is unreachable. >> >> Trying to investigate what else must be causing the wait. >> > > > > -- > SunilKalva