Does Consumer.poll () return new records even without bias?

If I have enable.auto.commit=false, and I call consumer.poll()without calling consumer.commitAsync()after, why does it consumer.poll()return new records on the next call?

Since I did not perform my offset, I would expect to poll()return the last offset, which should be the same records again.

I ask because I'm trying to process failure scenarios during my processing. I hoped, without committing the bias, poll()would return the same records again in order to repeat these failed records again.

public class MyConsumer implements Runnable {
    @Override
    public void run() {
        while (true) {
            ConsumerRecords<String, LogLine> records = consumer.poll(Long.MAX_VALUE);
            for (ConsumerRecord record : records) {
                try {
                   //process record
                   consumer.commitAsync();
                } catch (Exception e) {
                }
                /**
                If exception happens above, I was expecting poll to return new records so I can re-process the record that caused the exception. 
                **/
            }

        }
    }
}
+4
source share
1 answer

, . .

, , , , .

KafkaConsumer Javadoc, .

+3

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


All Articles