CHiRAG
CHiRAG

Reputation: 232

Runtime consume record from the offset in kafka spring boot

I want to read the record from the Kafka runtime passing parameter(offset). I am using a @KafkaListener but in that, I am unable to set the offset runtime of the user request. And if no offset is passed it will consume the latest records. Any help is appreciated.

Upvotes: 0

Views: 817

Answers (1)

Gary Russell
Gary Russell

Reputation: 174554

The latest 2.8 release has a new feature where you can use the KafkaTemplate to receive a specific record at a specific offset.

https://docs.spring.io/spring-kafka/docs/current/reference/html/#kafka-template-receive

If you want to receive all records from that offset, use the seek mechanisms provided by the container.

https://docs.spring.io/spring-kafka/docs/current/reference/html/#seek

Upvotes: 1

Related Questions