I use the spring-kafka annotation @KafkaListener to designate my listener method.
I consume a single topic with a single partition. The messages are never more than one or two a second so a single thread is acceptable. The spring-kafka docs say the @KafkaListener defaults to using a ConcurrentMessageListenerContainer. Is the correct way to control concurrency by using setConcurrency?
Or, should I be somehow create a KafkaMessageListenerContainer, which is single threaded?
I currently use this:
@Bean("appContainerFactory") KafkaListenerContainerFactory<ConcurrentMessageListenerContainer<Integer, String>> kafkaListenerContainerFactory() { ConcurrentKafkaListenerContainerFactory<Integer, String> factory = new ConcurrentKafkaListenerContainerFactory<>(); factory.setConcurrency(1); ... }