title: Generic Spring Kafka Listener
body: <p>I have made a kafka producer and consumer in one maven project.</p>
  
  <p>I want to use it in another maven project, so I added the dependency of the above kafka project. Now the problem is producer is fine but how to make listener generic that can be override by all other project which add this project.</p>
  
  <p>Currently I have Listener in one project </p>
  
  <pre><code>public class Listener {
      public CountDownLatch countDownLatch0 = new CountDownLatch(3);
      public CountDownLatch countDownLatch1 = new CountDownLatch(3);
      public CountDownLatch countDownLatch2 = new CountDownLatch(3);
  
      @KafkaListener(id = "id0", topicPartitions = { @TopicPartition(topic = "SpringKafkaTopic1", partitions = { "0" }) })
      public void listenPartition0(ConsumerRecord&lt;?, ?&gt; record) {
          System.out.println("Listener Id0, Thread ID: " + Thread.currentThread().getId());
          System.out.println("Received: " + record);
          countDownLatch0.countDown();
      }
  
      @KafkaListener(id = "id1", topicPartitions = { @TopicPartition(topic = "SpringKafkaTopic1", partitions = { "1" }) })
      public void listenPartition1(ConsumerRecord&lt;?, ?&gt; record) {
          System.out.println("Listener Id1, Thread ID: " + Thread.currentThread().getId());
          System.out.println("Received: " + record);
          countDownLatch1.countDown();
      }
  
      @KafkaListener(id = "id2", topicPartitions = { @TopicPartition(topic = "SpringKafkaTopic1", partitions = { "2" }) })
      public void listenPartition2(ConsumerRecord&lt;?, ?&gt; record) {
          System.out.println("Listener Id2, Thread ID: " + Thread.currentThread().getId());
          System.out.println("Received: " + record);
          countDownLatch2.countDown();
      }
  </code></pre>
  
  <p>How do I make generic listener which can be overriden by all other project who all add this project as dependency and can listen to their respective topics</p>