title: How to configure frequency for kafka consumer poll in spring-kafka
body: <p>I am trying to read messages from my kafka using spring-kafka in my spring boot project. I am using @KafkaListener but the issue is that my consumer is running always. As soon as I produce a message from console, It pops up in my application. I want to poll at regular intervals. How can I achieve this?</p>
  
  <pre><code>@Service
  public class KafkaReciever {
  
  private static final Logger LOGGER =
          LoggerFactory.getLogger(KafkaReciever.class);
  
  private CountDownLatch latch = new CountDownLatch(1);
  
  public CountDownLatch getLatch() {
      return latch;
  }
  
  @KafkaListener(topics = "test")
  public void receive(String payload) {
      LOGGER.info("received payload='{}'", payload);
      latch.countDown();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And here is my consumer config:</p>
  
  <pre><code>@Bean
  public Map&lt;String, Object&gt; consumerConfigs() {
      Map&lt;String, Object&gt; props = new HashMap&lt;&gt;();
  
      // list of host:port pairs used for establishing the initial connections to the Kafka cluster
      props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
      props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
      props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
  
      // allows a pool of processes to divide the work of consuming and processing records
      props.put(ConsumerConfig.GROUP_ID_CONFIG, "foo1");
  
      // automatically reset the offset to the earliest offset
      props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
  
      return props;
  }
  
  @Bean
  public ConsumerFactory&lt;String, String&gt; consumerFactory() {
      return new DefaultKafkaConsumerFactory&lt;&gt;(consumerConfigs());
  }
  
  @Bean
  public KafkaListenerContainerFactory&lt;ConcurrentMessageListenerContainer&lt;String, String&gt;&gt; kafkaListenerContainerFactory() {
      ConcurrentKafkaListenerContainerFactory&lt;String, String&gt; factory =
              new ConcurrentKafkaListenerContainerFactory&lt;&gt;();
      factory.setConsumerFactory(consumerFactory());
  
      return factory;
  }
  </code></pre>