Kafka consumer survey timeout

I work with Kafka and try to use data from it. From the line below, I can poll data from Kafka.

while (true) { ConsumerRecords<byte[], <byte[]> records = consumer.poll(Long.MAX_VALUE); for (ConsumerRecord<byte[], <byte[]> record : records) { // retrieve data } } 

My question is what benefit do I get by providing Long.MAX_VALUE as a timeout compared to if I provide 200 as a timeout. What is the best practice for a system that will launch production.

Can someone explain to me the difference in high timeout versus low timeout and which should be used in the production system?

+5
source share
1 answer

Setting MAX_VALUE is a kind of synchronous message, consuming, waiting forever, until we get something returned back from the poll, while setting it to a lower value gives you a chance that you can decide to do something else, except for the expectant. Which should be used depends on your actual scenario.

+2
source

Source: https://habr.com/ru/post/1260960/


All Articles