0

我正在 Kafka 中试用 Rest Proxy。

当我在浏览器中输入以下网址时http://192.168.0.30:8082/topics

我得到了预期的结果:

["__confluent.support.metrics","_confluent-command","_confluent-controlcenter-5-
2-2-1-MetricsAggregateStore-changelog","_confluent-controlcenter-5-2-2-1-actual-
group-consumption-rekey","_confluent-controlcenter-5-2-2-1-expected-group-
consumption-rekey","_confluent-controlcenter-5-2-2-1-metrics-trigger-measurement-
rekey","_confluent-ksql-default__command_topic","_confluent-metrics","_confluent-
monitoring","_schemas","connect-configs","connect-offsets","connect-
statuses","default_ksql_processing_log","test","test1"]


我的问题:我尽量不使用 CURL。我有以下 CURL 命令示例。如果我只想使用上述浏览器,我该如何更改?

我试过这个,但是......(我怎样才能消费我的话题test?) 在此处输入图像描述

**只是文档中的一个示例:**

# Create a consumer for binary data, starting at the beginning of the topic's
# log. Then consume some data from a topic.
$ curl -X POST -H "Content-Type: application/vnd.kafka.v1+json" \
      --data '{"id": "my_instance", "format": "binary", "auto.offset.reset": "smallest"}' \
      http://localhost:8082/consumers/my_binary_consumer
  {"instance_id":"my_instance","base_uri":"http://localhost:8082/consumers/my_binar
y_consumer/instances/my_instance"}

$ curl -X GET -H "Accept: application/vnd.kafka.binary.v1+json" \
      http://localhost:8082/consumers/my_binary_consumer/instances/my_instance/topics/test
  [{"key":null,"value":"S2Fma2E=","partition":0,"offset":0}]
4

2 回答 2

1

浏览器只能发出 GET 请求。

您可以使用 Postman 或 Insomnia 等工具来发出其他 HTTP 请求。

于 2019-07-31T14:59:25.147 回答
0

(供进一步参考)

我使用 Postman 来为 Kafka 使用 REST 代理。

1.我订阅了一个主题test

$ curl -X POST -H "Content-Type: application/vnd.kafka.v2+json" --data 
'{"topics":["test"]}' \   
http://192.168.0.30:8082/consumers/my_json_consumer/instances/my_consumer_instanc
e/subscription

(我改变了这个 CURL 以适应 Postman。)

在此处输入图像描述



2.然后,我消费了这个话题。

$ curl -X GET -H "Accept: application/vnd.kafka.json.v2+json" \
http://192.168.0.30:8082/consumers/my_json_consumer/instances/my_consumer_instanc
e/records

(我改变了这个 CURL 以适应 Postman。)

在此处输入图像描述

于 2019-08-01T02:02:38.627 回答