Jack
Jack

Reputation: 5880

How to indicate consumer offset in Kafka rest API

I'm using Kafka 0.10 REST API. I just used an HTTP object in Java to invoke the Kafka REST API (such as the curl commands). I need to indicate the consumer offset when I consume the message, otherwise it reads from the beginning or the latest, but I could not find the parameter to indicate the offset.

And is there a full REST proxy document to describe every parameter please.

Upvotes: 2

Views: 4771

Answers (2)

Alexandru Tetelea
Alexandru Tetelea

Reputation: 19

From https://docs.confluent.io/current/kafka-rest/docs/api.html

GET /topics/(string: topic_name)/partitions/(int: partition_id)/messages?offset=(int)[&count=(int)]

Upvotes: 1

Hans Jespersen
Hans Jespersen

Reputation: 8335

Assuming you mean the Confluent Kafka REST Proxy since Apache Kafka does not have a REST API for consuming messages.

Full docs are on the Confluent web site here

https://docs.confluent.io/current/kafka-rest/docs/api.html

Version 0.10 is the version of Apache Kafka but not the version of the Confluent REST Proxy. The Confluent release that includes Apache Kafka 0.10.0 is Confluent 3.0.0. There are many enhancements to the REST Proxy since this release several years ago so suggest that you upgrade to 4.0 or 4.1 and use the v2 REST API.

In the newer versions you can POST a list of offsets like this:

POST /consumers/testgroup/instances/my_consumer/offsets HTTP/1.1
Host: proxy-instance.kafkaproxy.example.com
Content-Type: application/vnd.kafka.v2+json

{
  "offsets": [
    {
      "topic": "test",
      "partition": 0,
      "offset": 20
    },
    {
      "topic": "test",
      "partition": 1,
      "offset": 30
    }
  ]
}

Upvotes: 3

Related Questions