SpringSpring Kafka Configuration
How do you control the number of messages processed per @KafkaListener invocation?
Reference answer
Set spring.kafka.consumer.max-poll-records (maps to max.poll.records Kafka property, default 500). In RECORD mode, listener is called once per record. In BATCH mode, listener is called with a List<ConsumerRecord> containing up to max-poll-records messages. To further control batch size, tune fetch.min.bytes and fetch.max.wait.ms — larger values accumulate more messages before returning. For controlled throughput limiting, use a ThreadPoolTaskExecutor with a fixed pool size and bounded queue in the listener method.
Expected key concepts: max-poll-records, RECORD mode, BATCH mode, List<ConsumerRecord>, fetch.min.bytes, fetch.max.wait.ms, ThreadPoolTaskExecutor, bounded queue, throughput limiting, invocation