2
votes

In my application, I created my own custom listener in order to not use the @KafkaListener annotation. I configured to listen the messages in a record to record bases. That is working. Now I want to transform my custom listener to listen to messages in a batch. Should I just configure the ConsumerConfig.MAX_POLL_RECORDS_CONFIG to the amount of message I want to process per poll? I would also change my AckMode to BATCH. Is this all I need to do?

I know that ConcurrentKafkaListenerContainerFactory has the property "setBatchListener(true)", but as far as I understand the Kafka documentation, this type of factory configuration is only utilized with the @KafkaListener annotation.

Any help will be greatly appreciated.

1
the max poll records is a limit, not a hard-number; you might still need to increase the poll timeoutOneCricketeer

1 Answers

0
votes

Just change your listener to implement BatchMessageListener or one of its sub-interfaces instead. The container will automatically detect its type.

See Message Listeners.

The @KafkaListener code uses the factory flag to determine which type of listener adapter to create.