【问题标题】:How to change Kafka Rest Proxy CURL command in order to use it in a browser如何更改 Kafka Rest Proxy CURL 命令以便在浏览器中使用它
【发布时间】:2019-07-31 09:13:35
【问题描述】:

我正在 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}]

【问题讨论】:

    标签: apache-kafka kafka-rest


    【解决方案1】:

    浏览器只能发出 GET 请求。

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

    【讨论】:

      【解决方案2】:

      (供进一步参考)

      我使用 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。)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-02-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-01-25
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多