I have a producer which push meassages to Kafa topic using REST API. Now how can I have a consumer which can consume those meassges using REST API.
I have tried using @GetMapping but it did not worked
I have a producer which push meassages to Kafa topic using REST API. Now how can I have a consumer which can consume those meassges using REST API.
I have tried using @GetMapping but it did not worked
Confluent platform has REST proxy which exposes Kafka topics over REST. It allows you to use REST to produce consume data to a topic. See example here
A sample for consuming json data from a topic
Create a consumer for JSON data, starting at the beginning of the topic's log and subscribe to a topic. Then consume some data using the base URL in the first response. Finally, close the consumer with a DELETE to make it leave the group and clean up its resources.
$ 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