title: Spring Kafka with Dynamic @KafkaListener
body: <p>I'm using Spring Boot 2.x with <strong>spring-kafka</strong> (not <strong>spring-integration-kafka</strong>)</p>
  
  <p>I have multiple beans annotated with <code>@KafkaListener</code> ... each one consuming from one topic... so since I have 12 topics then I also need to have 12 KafkaConsumers beans ... and I would like to know if I can create those beans programmatically / dynamically  ... maybe using <strong>KafkaListenerEndpointRegistry</strong> in order to create consumer containers dynamically.</p>
  
  <p>Note: I need to consume messages in batch ... so maybe I can use <strong>BatchMessageListener</strong>?</p>
  
  <p>Current code:</p>
  
  <pre><code>@KafkaListener(
          id = COUNTRY,
          containerFactory = KAFKA_LISTENER_FACTORY_BEAN_NAME,
          topics = {TOPIC},
          groupId = GROUP_ID,
          clientIdPrefix = CLIENT_ID,
          errorHandler = VALIDATION_ERROR_HANDLER_BEAN_NAME
      )
      @Override
      public void consume(final List&lt;MessageDTO&gt; messages,
          @Header(KafkaHeaders.RECEIVED_TOPIC) final List&lt;String&gt; topics,
          @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) final List&lt;String&gt; messagesKey,
          @Header(KafkaHeaders.RECEIVED_PARTITION_ID) final List&lt;Integer&gt; partitionIds,
          @Header(KafkaHeaders.RECEIVED_TIMESTAMP) final List&lt;Long&gt; timestamps,
          @Header(KafkaHeaders.OFFSET) final List&lt;Long&gt; offsets) {
              (...)
      }
  </code></pre>
  
  <p>Each topic consumer has its own implementation depending on the topic. Can you guys point me to a blog/pseudocode/git thread/answer, please?</p>