我有一个生产者,推动meassages到kafa主题使用restapi。现在我怎样才能有一个消费者可以使用restapi来消费这些度量。我尝试过使用@getmapping,但没有成功
n3ipq98p1#
confluent平台有rest代理,它在rest之上公开kafka主题。它允许您使用rest生成主题的消费数据。请看这里的示例使用主题中的json数据的示例为json数据创建一个使用者,从主题日志的开头开始,订阅一个主题。然后在第一个响应中使用基本url使用一些数据。最后,使用delete关闭使用者,使其离开组并清理其资源。
$ curl -X POST -H "Content-Type: application/vnd.kafka.v2+json" \ --data '{"name": "my_consumer_instance", "format": "json", "auto.offset.reset": "earliest"}' \ http://localhost:8082/consumers/my_json_consumer {"instance_id":"my_consumer_instance", "base_uri":"http://localhost:8082/consumers/my_json_consumer/instances/my_consumer_instance"} $ curl -X POST -H "Content-Type: application/vnd.kafka.v2+json" --data '{"topics":["jsontest"]}' \ http://localhost:8082/consumers/my_json_consumer/instances/my_consumer_instance/subscription $ curl -X GET -H "Accept: application/vnd.kafka.json.v2+json" \ http://localhost:8082/consumers/my_json_consumer/instances/my_consumer_instance/records [{"key":null,"value":{"foo":"bar"},"partition":0,"offset":0,"topic":"jsontest"}] $ curl -X DELETE -H "Content-Type: application/vnd.kafka.v2+json" \ http://localhost:8082/consumers/my_json_consumer/instances/my_consumer_instance
1条答案
按热度按时间n3ipq98p1#
confluent平台有rest代理,它在rest之上公开kafka主题。它允许您使用rest生成主题的消费数据。请看这里的示例
使用主题中的json数据的示例
为json数据创建一个使用者,从主题日志的开头开始,订阅一个主题。然后在第一个响应中使用基本url使用一些数据。最后,使用delete关闭使用者,使其离开组并清理其资源。