Spring @KafkaListener execute and poll records after certain interval

后端 未结 3 713
感动是毒
感动是毒 2020-12-17 04:16

We wanted to consume the records after a certain interval (e.g. every 5 minutes). Consumer properties are standard:

@Bean
public KafkaListenerContainerFactor         


        
3条回答
  •  鱼传尺愫
    2020-12-17 04:34

    You cannot control the rate at which the consumer polls, the pollTimeout is how long the poll() will wait for new records to arrive. If new records arrive more often, it will not wait that long.

    If you wish to control the rate at which you receive records, simply use the DefaultKafkaConsumerFactory to create a consumer and poll it whenever you want.

    You can't use that with a @KafkaListener though - you have to deal with the record yourself.

提交回复
热议问题