Well, I'm trying the following scenario:
- In application.properties set max.poll.records to 50.
- In application.properties set enable-auto-commit=false and ack-mode to manual.
- In my method added @KafkaListener, but don't commit any message, just read, log but don't make an ACK.
Actually, in my Kafka topic, I have 500 messages to be consumed, so I'm expecting the following behavior:
- Spring Kafka poll() 50 messages (offset 0 to 50).
- As I said, I didn't commit anything, just log the 50 messages.
- In the next Spring Kafka poll() invocation, get the same 50 messages (offset 0 to 50), as step 1. Spring Kafka, in my understanding, should continue in this loop (step 1-3) reading always the same messages.
But what happens is the following:
- Spring Kafka poll() 50 messages (offset 0 to 50).
- As I said, I didn't commit anything, just log the 50 messages.
- In the next Spring Kafka poll() invocation, get the NEXT 50 messages, different from step 1 (offset 50 to 100).
Spring Kafka reads the 500 messages, in blocks of 50 messages, but don't commit anything. If I shut down the application and start again, the 500 messages are received again.
So, my doubts:
- If I configured the max.poll.recors to 50, how spring Kafka get the next 50 records if I didn't commit anything? I understand the poll() method should return the same records.
- Does Spring Kafka have some cache? If yes, this can be a problem if I get 1million records in cache without commit.