Marcus Nilsson
Marcus Nilsson

Reputation: 33

How do I disable committing of offsets in Spring Kafka to store offsets locally?

I want to use Spring Kafka to process events into a local database and store the offset in the database itself, as described in https://kafka.apache.org/25/javadoc/index.html?org/apache/kafka/clients/consumer/KafkaConsumer.html under "Storing Offsets Outside Kafka".

Spring Kafka (with a KafkaListener) seems to always commit offsets though (and thus requires a group.id), is there a way to disable commits altogether allowing to listen without a group?

Upvotes: 2

Views: 3357

Answers (2)

Gary Russell
Gary Russell

Reputation: 174719

Container property AckMode.MANUAL will disable offset commits by the container.

Upvotes: 0

Nic Pegg
Nic Pegg

Reputation: 503

Spring Kafka Consumer has a configuration property enable.auto.commit. This can be set to false so that you can implement a commit strategy in your code. Please see the documentation here: https://docs.spring.io/spring-kafka/reference/html/#committing-offsets

The KafkaListener annotation can have configuration defined directly. Please see the JavaDoc - https://docs.spring.io/spring-kafka/api/org/springframework/kafka/annotation/KafkaListener.html.

Upvotes: 0

Related Questions