title: Kafka consumer client creation singleton instance vs static method
body: <p>Please tell which one is the best practice to create Kafka consumer client. </p>
  
  <pre><code>public class KafkaConsumerFactory {
  
  public static createKafKafkaConsumer(){
         KafkaConsumer consumer = new KafkaConsumer&lt;   (getKafkaConsumerProperties());
        consumer.subscribe(Collections.Singleton.(getTopic()));
        return consumer;
  }
  </code></pre>
  
  <p>Or </p>
  
  <pre><code>public class KafkaConsumerFactory {
  
  private static KafkaConsumer consumer;  
  
  @Synchronized
  public static KafkaConsumer createKafKafkaConsumer(){
  
  if(consumer = null)
      {
        consumer = new KafkaConsumer&lt; (getKafkaConsumerProperties());
        consumer.subscribe(Collections.Singleton.(getTopic()));
      }
  
   return consumer;
  }
  }
  </code></pre>
  
  <p>Will there be any considerable benefit in having singleton Kafka consumer client in production environment ?</p>