kostja
kostja

Reputation: 61538

How to get the offsets programmatically with Kafka 1.0

The OffsetRequest has been deprecated for a while, along with almost all the other classes in kafka.api and now has been removed in 1.0. However, neither the deprecation message nor the docs explain what can be used instead.

The FAQ is not helpful for this topic.

There are CLI tools for this, but I have not found any advice on doing it programmatically.

Upvotes: 3

Views: 1028

Answers (1)

Mickael Maison
Mickael Maison

Reputation: 26885

The classes in kafka.api are for the old clients (in Scala) that are deprecated and will be removed in a future release.

The new Java clients are using the classes defined in org.apache.kafka.common.requests.

The class org.apache.kafka.common.requests.ListOffsetRequest is the replacement for the old OffsetRequest.

The following methods from KafkaConsumer can be used to retrieve offsets (they all send a ListOffsetRequest from the client):

Upvotes: 2

Related Questions