Skip to content

Instantly share code, notes, and snippets.

@flinox
Last active February 19, 2019 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flinox/68019a2e0cdc6df265fcbd0a71dc2c6f to your computer and use it in GitHub Desktop.
Save flinox/68019a2e0cdc6df265fcbd0a71dc2c6f to your computer and use it in GitHub Desktop.
Kafka: Consume message in avro format of a kafka topic with api of confluent REST proxy
-- CREATE CONSUMER
curl --request POST \
--url http://{{hostname_rest_proxy}}:8082/consumers/consumer-group-x \
--header 'content-type: application/vnd.kafka.v2+json' \
--data '{
"name": "client_x",
"format": "avro",
"auto.offset.reset": "latest",
"auto.commit.enable": "false"
}'
-- SUBSCRIBE CONSUMER
curl --request POST \
--url http://{{hostname_rest_proxy}}:8082/consumers/consumer-group-x/instances/client_x/subscription \
--header 'content-type: application/vnd.kafka.v2+json' \
--data '{
"topics": [
"topic-name"
]
}'
-- CONSOME AVRO
curl --request GET \
--url 'http://{{hostname_rest_proxy}}:8082/consumers/consumer-group-x/instances/client_x/records?timeout=6000&max_bytes=250000' \
--header 'accept: application/vnd.kafka.avro.v2+json'
-- COMMIT OFFSETS
curl --request POST \
--url http://{{hostname_rest_proxy}}:8082/consumers/consumer-group-x/instances/client_x/offsets \
--header 'content-type: application/vnd.kafka.v2+json' \
--data '
{
"offsets": [
{
"topic": "topic-name",
"partition": 0,
"offset": 1
}
]
}'
-- DELETE CONSUMER
curl --request DELETE \
--url http://{{hostname_rest_proxy}}:8082/consumers/consumer-group-x/instances/client_x \
--header 'content-type: application/vnd.kafka.v2+json'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment