Spring boot application reads messages from kafka after deleting them

I have spring boot application which reads messages from Kafka and I can't understand one behavior. I have set kafka properties regarding max poll size to:

spring:
  kafka:
    consumer:
      max-poll-records: 5
    listener:
      ack-mode: record
      concurrency: 1
logging:
  level:
    org.springframework.kafka.listener.KafkaMessageListenerContainer: DEBUG

And I can see that messages are read in packages by 5 in each:

2023-08-04T13:21:25.053+02:00 DEBUG [,] 12001 --- [ntainer#0-0-C-1] o.s.k.l.KafkaMessageListenerContainer    : Received: 5 records
//Handling first 4 messages
2023-08-04T13:21:57.114+02:00  INFO [,] 12001 --- [ntainer#0-0-C-1] SomeListener: Handling command message

2023-08-04T13:22:05.134+02:00 DEBUG [,] 12001 --- [ntainer#0-0-C-1] o.s.k.l.KafkaMessageListenerContainer    : Received: 5 records
2023-08-04T13:22:05.135+02:00  INFO [,] 12001 --- [ntainer#0-0-C-1] SomeListener: Handling command message
//Handling next 4 messages

I sent 200 messages to topic and deleted them (with kafka-ui and also by setting retention.ms) after processing started to check if application really fetch 5 messages in poll. But even if messages are not in the topic application still is able to read all messages which are sent. I can't understand why. Is it a normal behaviour that kafka allows consumer which already started to read all messages, even these deleted?



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation