Search code examples
spring-bootapache-kafkaspring-cloud-streamconsumerspring-cloud-stream-binder-kafka

spring cloud stream kafka batch does not consume messages in every 15 minutes even after increasing this config, 'fetch.max.wait.ms'


I want to consume message in batch mode in every 15 minutes. For that I have set these properties,

spring.cloud.stream.kafka.binder.consumer-properties.max.poll.records=5000000
spring.cloud.stream.kafka.binder.consumer-properties.fetch.max.wait.ms=900000
spring.cloud.stream.kafka.binder.consumer-properties.fetch.min.bytes=500000000

Consuming message works fine when I set this property spring.cloud.stream.kafka.binder.consumer-properties.fetch.max.wait.ms between 10000 to 30000, 10seconds or 30 seconds. But If I increase the fetch.max.wait.ms to 1 minutes or more, It doesn't consumes messages even the waiting time is over.

I know the default value is 500ms, but will there be an issue if I increase that??

And How can I get the desired behaviour (consumer to wait for 10-15min before consuming the batch again)??

Can I use max.poll.interval.ms for that?


Solution

  • I was able to consume messages in every 15 minutes by setting these properties.

    spring.cloud.stream.kafka.binder.consumer-properties.max.poll.interval.ms=1000000
    

    And

    setting idleTime between polls using container property.

      @Bean
      public ListenerContainerCustomizer<AbstractMessageListenerContainer<?, 
      ?>> customizer() {
        return (container, dest, group) -> 
    container.getContainerProperties().setIdleBetweenPolls(idlePollTimeout);
    
      }