title: kafka java producer stuck in producing message
body: <p>I am implementing apache kafka producer using java api. Apache Kafka is installed on localhost. Zookeeper is also running but still producer.send() function stuck in sending message and message is not published.</p>
  
  <p>I have already created "fast-messages" topic.</p>
  
  <p>Below is the code.</p>
  
  <pre><code>package com.hsahu.kafka.producer;
  
  import java.util.Properties;
  import org.apache.kafka.clients.producer.KafkaProducer;
  import org.apache.kafka.clients.producer.ProducerRecord;
  
  public class KafkaProducerExample {
  public static void main(String[] args) {
  
      Properties props = new Properties();
  
      props.put("bootstrap.servers", "localhost:9092");
      props.put("acks", "all");
      props.put("retries", 0);
      props.put("batch.size", 16384);
      props.put("linger.ms", 0);
      props.put("buffer.memory", 33554432);
      props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
      props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
  
      KafkaProducer&lt;String, String&gt; producer = new KafkaProducer&lt;&gt;(props);
  
      try {
          producer.send(new ProducerRecord&lt;String, String&gt;("fast-messages", "This is a dummy message"));
      } catch(Exception ex) {
          System.out.println(ex);
      }
  
      System.out.println("message publisher");
  
      producer.close();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>What should i do ? is my code wrong or any properties not set correctly or missing ?</p>