简体   繁体   English

如何在Kafka Rest API中指示使用者偏移量

[英]How to indicate consumer offset in Kafka rest API

I'm using Kafka 0.10 REST API. 我正在使用Kafka 0.10 REST API。 I just used an HTTP object in Java to invoke the Kafka REST API (such as the curl commands). 我只是在Java中使用HTTP对象来调用Kafka REST API(例如curl命令)。 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. 并有完整的REST代理文档来描述每个参数。

Assuming you mean the Confluent Kafka REST Proxy since Apache Kafka does not have a REST API for consuming messages. 假设您的意思是Confluent Kafka REST代理,因为Apache Kafka没有用于消费消息的REST API。

Full docs are on the Confluent web site here 完整文档位于此处的Confluent网站上

https://docs.confluent.io/current/kafka-rest/docs/api.html 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. 版本0.10是Apache Kafka的版本,而不是Confluent REST代理的版本。 The Confluent release that includes Apache Kafka 0.10.0 is Confluent 3.0.0. 包含Apache Kafka 0.10.0的Confluent版本是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. 自从几年前发布此版本以来,REST代理有了许多增强功能,因此建议您升级到4.0或4.1并使用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
    }
  ]
}

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM