This shows how to use httpie with the Confluent REST Proxy.
Send data 🔗
echo '{"records":[{"value":{"foo":"bar"}}]}' | \
http POST http://localhost:8082/topics/jsontest \
Content-Type:application/vnd.kafka.json.v2+json Accept:application/vnd.kafka.v2+json
Response:
HTTP/1.1 200 OK
Content-Encoding: gzip
Content-Length: 100
Content-Type: application/vnd.kafka.v2+json
Date: Fri, 08 Mar 2019 15:24:53 GMT
Server: Jetty(9.4.12.v20180830)
Vary: Accept-Encoding, User-Agent
{
"key_schema_id": null,
"offsets": [
{
"error": null,
"error_code": null,
"offset": 3,
"partition": 0
}
],
"value_schema_id": null
}
Consume data 🔗
Create a consumer 🔗
echo '{"name": "rmoff_consumer_instance", "format": "json", "auto.offset.reset": "earliest"}' | \
http POST http://localhost:8082/consumers/rmoff_consumer_group \
Content-Type:application/vnd.kafka.v2+json
Response:
HTTP/1.1 200 OK
Content-Encoding: gzip
Content-Length: 109
Content-Type: application/vnd.kafka.v2+json
Date: Fri, 08 Mar 2019 15:28:13 GMT
Server: Jetty(9.4.12.v20180830)
Vary: Accept-Encoding, User-Agent
{
"base_uri": "http://rest-proxy:8082/consumers/rmoff_consumer_group/instances/rmoff_consumer_instance",
"instance_id": "rmoff_consumer_instance"
}
Create a subscription for the consumer 🔗
echo '{"topics":["jsontest"]}' | \
http POST http://localhost:8082/consumers/rmoff_consumer_group/instances/rmoff_consumer_instance/subscription \
Content-Type:application/vnd.kafka.v2+json
Response
HTTP/1.1 204 No Content
Date: Fri, 08 Mar 2019 15:30:33 GMT
Server: Jetty(9.4.12.v20180830)
Read all available messages 🔗
http http://localhost:8082/consumers/rmoff_consumer_group/instances/rmoff_consumer_instance/records \
Accept:application/vnd.kafka.json.v2+json
Response:
HTTP/1.1 200 OK
Content-Encoding: gzip
Content-Length: 113
Content-Type: application/vnd.kafka.json.v2+json
Date: Fri, 08 Mar 2019 15:31:42 GMT
Server: Jetty(9.4.12.v20180830)
Vary: Accept-Encoding, User-Agent
[
{
"key": null,
"offset": 0,
"partition": 0,
"topic": "jsontest",
"value": {
"foo": "bar"
}
}
]
Change the offset for the consumer 🔗
This is useful if you want to reconsume messages, or maybe seek past a bad message.
echo '{ "offsets": [ { "topic": "jsontest", "partition": 0, "offset": 1 } ] }' | \
http POST localhost:8082/consumers/rmoff_consumer_group/instances/rmoff_consumer_instance/positions \
Content-Type:application/vnd.kafka.v2+json
Response:
HTTP/1.1 204 No Content
Date: Fri, 08 Mar 2019 15:54:48 GMT
Server: Jetty(9.4.12.v20180830)
Delete the consumer 🔗
http DELETE http://localhost:8082/consumers/rmoff_consumer_group/instances/rmoff_consumer_instance \
Content-Type:application/vnd.kafka.v2+json
Response:
HTTP/1.1 204 No Content
Date: Fri, 08 Mar 2019 15:33:06 GMT
Server: Jetty(9.4.12.v20180830)