title: Kafka Java Producer with Kerberos authentication
body: <p>I have gone through <a href="https://stackoverflow.com/questions/35934578/kafka-java-producer-with-kerberos/36334085">this</a> question before posting the question. It was using 0.8.0 version of Kafka producer code.</p>
  
  <p>We are using <code>Kafka 0.9.0.1 version</code>. Since our cluster is secured one using <code>Kerberos authentication</code>. How can i set the Kerberos authentication details programatically?</p>
  
  <p>When i try to send the message , the message is not reaching to Kafka topic. I confirmed this using getting the result of Async <code>send</code> operation from the Producer <code>Future&lt;RecordMetadata&gt;</code> and it was throwing the timeout exception.</p>
  
  <p><strong>Sample Code:</strong></p>
  
  <pre><code>Properties props = new Properties();
          props.put("bootstrap.servers", "1.2.3.4:6667");
          props.put("acks", "all");
          props.put("retries", 2);
  //      props.put("security.inter.broker.protocol","PLAINTEXTSASL");
          props.put("security.protocol", "PLAINTEXTSASL");//WHEN I TRY THIS ITS THROWING ERROR
          props.put("sasl.kerberos.service.name","zookeeper");
          props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
          props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
  
          try {
              Producer&lt;String, String&gt; producer = new KafkaProducer&lt;&gt;(props);
              producer.send(new ProducerRecord&lt;String, String&gt;("kafkaTest", "kafka test message"));
              // Thread.sleep(4000);
              // producer.close();
          } catch (Exception e) {
              e.printStackTrace();
          }
  </code></pre>
  
  <p>Do i have to change anything on the <code>jaas</code> file? I dont see any documentation for Java API with Kerberos authentication.</p>
  
  <p><strong>The timeout exception is:</strong></p>
  
  <pre><code>java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.
      at org.apache.kafka.clients.producer.KafkaProducer$FutureFailure.&lt;init&gt;(KafkaProducer.java:686)
      at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:449)
      at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:339)
      at com.scb.upv.SimpleKafkaProducer.main(SimpleKafkaProducer.java:26)
  Caused by: org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.
  </code></pre>