BeginnerCore Concepts
What is the difference between Kafka's @KafkaListener and manual polling?
Reference answer
@KafkaListener (Spring for Apache Kafka) marks a bean method as a listener for a listener container: the bean is wrapped in a MessagingMessageListenerAdapter that converts the data to match the method parameters. It needs @EnableKafka and a listener container factory (by default a bean named kafkaListenerContainerFactory) that configures the underlying ConcurrentMessageListenerContainer. The container runs the consumer poll() loop for you: each KafkaMessageListenerContainer consumes on a single thread, and the concurrency setting creates several of them. The container also handles offset commits (the default AckMode is BATCH, committing once all records returned by a poll() are processed, and enable.auto.commit is set to false unless you set it) and error handling (the DefaultErrorHandler retries a failed record, FixedBackOff(0L, 9) by default, and then logs it). With manual polling you create a KafkaConsumer, call poll() in your own loop, and handle exceptions, offset commits and thread safety yourself, since KafkaConsumer is not thread-safe. The listener container is the common choice in Spring applications; manual polling gives full control.
Expected key concepts: @KafkaListener, @EnableKafka, listener container, ConcurrentMessageListenerContainer, AckMode, BATCH, DefaultErrorHandler, KafkaConsumer, poll, offset commit
How did that feel?
Your own verdict, not the score. It shows up next to this question in the list, so you can come back to the shaky ones.