You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Joe San <co...@gmail.com> on 2016/01/26 17:50:22 UTC

No Kafka Error when no Server

Is this strange or wierd? I had no Kafka or Zookeeper running on my local
machine and I was expecting an exception, but for some strange reason, I do
not see any errors:

try {
  logger.info(s"kafka producer obtained is ${producer}")
  producer.send(
    new ProducerRecord[String, String](producerConfig.topic, jsonMessage)
  )
} catch {
  case x: Throwable => logger.error(s"shit happened ******* ${x.getMessage}")
}

Re: No Kafka Error when no Server

Posted by Gwen Shapira <gw...@confluent.io>.
Producer.send() by itself will not throw anything.

You need to either wait on the future:
producer.send().get()

Or to use it with a callback that logs the error.

On Tue, Jan 26, 2016 at 8:50 AM, Joe San <co...@gmail.com> wrote:

> Is this strange or wierd? I had no Kafka or Zookeeper running on my local
> machine and I was expecting an exception, but for some strange reason, I do
> not see any errors:
>
> try {
>   logger.info(s"kafka producer obtained is ${producer}")
>   producer.send(
>     new ProducerRecord[String, String](producerConfig.topic, jsonMessage)
>   )
> } catch {
>   case x: Throwable => logger.error(s"shit happened *******
> ${x.getMessage}")
> }
>