Hi Samuel, you can use *metadata.fetch.timeout.ms <http://metadata.fetch.timeout.ms> *property to reduce the blocking time while cluster is unreachable. The default value of this property is 1min.
*waitOnMetadata*() is blocking call which blocks current thread waiting for the metadata fetch to succeed before throwing an excaption back to client. On Fri, Mar 20, 2015 at 11:29 AM, Samuel Chase <samebch...@gmail.com> wrote: > Hello Everyone, > > In the the new Java Producer API, the Callback code in > KafkaProducer.send is run after there is a response from the Kafka > server. This can be used if some error handling needs to be done based > on the response. > > When using the new Java Kafka Producer, I've noticed that when the > Kafka server is down/unreachable, KafkaProducer.send blocks until the > Kafka server is back up again. > > We've been using the older Scala Producer and when Kafka is > unreachable it throws an exception after a few retries. This exception > is caught and then some error handling code is run. > > - What is the recommended way of using the new Java Producer API to > handle the case where Kafka is unreachable temporarily? > > I don't want to wait until it is reachable again before I know that > the send failed. > > Any help, advice shall be much appreciated. > > Samuel >