Last active
February 19, 2019 10:57
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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