如何在kafkarestapi中表示使用者偏移量

vddsk6oq  于 2021-06-07  发布在  Kafka
关注(0)|答案(2)|浏览(306)

我使用的是kafka0.10restapi。我只是在java中使用了一个http对象来调用kafkarestapi(比如curl命令)。当我使用消息时,我需要指示使用者偏移量,否则它从开始或最新读取,但我找不到指示偏移量的参数。
有完整的rest代理文件来描述每个参数吗。

kiz8lqtg

kiz8lqtg1#

假设您指的是合流的kafka rest代理,因为apachekafka没有用于消费消息的restapi。
完整的文档在这里的合流网站上
https://docs.confluent.io/current/kafka-rest/docs/api.html
版本0.10是apachekafka的版本,但不是合流rest代理的版本。包含apachekafka0.10.0的合流版本是合流3.0.0。自几年前的这个版本以来,rest代理有许多增强,因此建议您升级到4.0或4.1并使用v2restapi。
在较新版本中,您可以发布如下偏移列表:

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
    }
  ]
}
ct2axkht

ct2axkht2#

从https://docs.confluent.io/current/kafka-rest/docs/api.html GET /topics/(string: topic_name)/partitions/(int: partition_id)/messages?offset=(int)[&count=(int)]

相关问题