Spring boot : Kafka commits offset
I have a very simple application :
@KafkaListener(topics = "journal-topic")
public void onMessage(ConsumerRecord<String,String> consumerRecord, Acknowledgment acknowledgment) {
acknowledgment.acknowledge();
var message = extractMessage(consumerRecord);
messageService.saveOrUpdateMessage(message);
}
extractMessage(consumerRecord)
throws an Exception
(IllegalArgumentException
) but what happens is during my unit tests, there a 6 retries. I don’t understand why.
I acknowledge()
as soon as I entered the method, before the exception was thrown. So it should be considered fine, and no retry should happen I think.
Here is my config :
kafka:
topic: "journal-topic"
properties:
auto-create-topics-enable: true
consumer:
bootstrap-servers: localhost:9092
group-id: "journal-group"
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
auto-offset-reset: latest
max-poll-records: 10
enable-auto-commit: false
listener:
ack-mode: manual_immediate
concurrency: 3
Read more here: Source link