title: Spring Kafka concurrency with spring-integration
body: <p>I cannot tell if I'm missing something obvious, or there is a bug in <code>spring-integration-kafka:3.0.1</code> for trying to have multiple consumers running for a topic. The scenario is a single Kafka topic with 10 partitions, and a single springboot-app that listens to it. Relevant configuration is:</p>
  
  <p>application.yml:</p>
  
  <pre><code>spring:
    kafka:
      consumer:
        group-id: test-consumer
        auto-offset-reset: earliest
      listener:
        concurrency: 4
  </code></pre>
  
  <p>Configuration:</p>
  
  <pre><code>@Configuration
  @EnableIntegration
  @IntegrationComponentScan("com.test")
  public class MessageConfig {
      @Bean
      public MessageChannel testReceiveChannel() {
          return MessageChannels.direct().get();
      }
  
      @Bean
      public IntegrationFlow testReceiveFlow(@Qualifier("kafkaConsumerFactory") final ConsumerFactory&lt;?, ?&gt; kafkaConsumer, final MessageChannel testReceiveChannel) {
          return IntegrationFlows
                  .from(Kafka.messageDrivenChannelAdapter(kafkaConsumer, ListenerMode.record, "test-topic"))
                  .transform(new JsonToObjectTransformer(EventMessage.class))
                  .channel(testReceiveChannel)
                  .get();
      }
  }
  </code></pre>
  
  <p>Listener:</p>
  
  <pre><code>@Component
  public class EventListener {
      private static final Logger LOG = LoggerFactory.getLogger(EventListener.class);
  
      @ServiceActivator(inputChannel = "testReceiveChannel")
      public void processMessage(final EventMessage message) {
          LOG.info("Got message {} on {}", message.getValue(), Thread.currentThread().getName());
      }
  }
  </code></pre>
  
  <p>When started, I only get 1 container listening on all 10 partitions. I can see that <code>ConcurrentKafkaListenerContainerFactory</code> has the proper concurrency value set on it, but it appears it's <code>initializeContainer</code> method is never called (which would apply it to the actual consumer, if I understand it correctly). I am probably looking at the completely wrong thing however.</p>
  
  <p>Any idea on what I'm overlooking?</p>