Java Shell
Switch branches/tags
v5.1.0-beta201806200051 v5.1.0-beta201806191956 v5.1.0-beta39 v5.1.0-beta38 v5.1.0-beta37 v5.1.0-beta36 v5.1.0-beta35 v5.1.0-beta34 v5.1.0-beta180707004950 v5.1.0-beta180706202701 v5.1.0-beta180703024529 v5.1.0-beta180702220040 v5.1.0-beta180702214311 v5.1.0-beta180702063440 v5.1.0-beta180702063039 v5.1.0-beta180701175749 v5.1.0-beta180701010040 v5.1.0-beta180630224439 v5.1.0-beta180628184841 v5.1.0-beta180628064520 v5.1.0-beta180627203509 v5.1.0-beta180626014959 v5.1.0-beta180622181348 v5.1.0-beta180620183559 v5.1.0-beta180620180739 v5.1.0-beta180620180431 v5.1.0-beta180619025141 v5.1.0-beta180618225004 v5.1.0-beta180618223247 v5.1.0-beta180618214711 v5.1.0-beta180618191747 v5.1.0-beta180615005408 v5.1.0-beta180614233101 v5.1.0-beta180613013021 v5.1.0-beta180612224009 v5.1.0-beta180612043613 v5.1.0-beta180611231144 v5.0.0-beta33 v5.0.0-beta32 v5.0.0-beta31 v5.0.0-beta30 v5.0.0-beta29 v5.0.0-beta28 v5.0.0-beta27 v5.0.0-beta26 v5.0.0-beta25 v5.0.0-beta24 v5.0.0-beta23 v5.0.0-beta22 v5.0.0-beta21 v5.0.0-beta20 v5.0.0-beta19 v5.0.0-beta18 v5.0.0-beta17 v5.0.0-beta16 v5.0.0-beta15 v5.0.0-beta14 v5.0.0-beta12 v5.0.0-beta11 v5.0.0-beta10 v5.0.0-beta9 v5.0.0-beta8 v5.0.0-beta7 v5.0.0-beta6 v5.0.0-beta5 v5.0.0-beta3 v5.0.0-beta2 v5.0.0-beta1 v5.0.0-beta180707072142 v5.0.0-beta180707005130 v5.0.0-beta180706202823 v5.0.0-beta180702222458 v5.0.0-beta180702185100 v5.0.0-beta180701205239 v5.0.0-beta180701175910 v5.0.0-beta180701053749 v5.0.0-beta180701010229 v5.0.0-beta180630224559 v5.0.0-beta180629053850 v5.0.0-beta180628221539 v5.0.0-beta180628184550 v5.0.0-beta180627203620 v5.0.0-beta180626015140 v5.0.0-beta180622225242 v4.1.2-beta3 v4.1.1 v4.1.1-rc3 v4.1.1-rc2 v4.1.1-rc1 v4.1.0 v4.1.0-rc4 v4.1.0-rc3 v4.1.0-rc2 v4.1.0-rc1 v4.0.2 v4.0.2-rc1 v4.0.2-beta4 v4.0.1 v4.0.1-rc2 v4.0.1-rc1
Nothing to show
Clone or download
Latest commit 32b4f8d Jul 17, 2018

README.md

Kafka REST Proxy

The Kafka REST Proxy provides a RESTful interface to a Kafka cluster. It makes it easy to produce and consume messages, view the state of the cluster, and perform administrative actions without using the native Kafka protocol or clients. Examples of use cases include reporting data to Kafka from any frontend app built in any language, ingesting messages into a stream processing framework that doesn't yet support Kafka, and scripting administrative actions.

Installation

You can download prebuilt versions of the Kafka REST Proxy as part of the Confluent Platform.

You can read our full installation instructions and the complete documentation

To install from source, follow the instructions in the Development section below.

Deployment

The REST proxy includes a built-in Jetty server. The wrapper scripts bin/kafka-rest-start and bin/kafka-rest-stop are the recommended method of starting and stopping the service.

Quickstart

The following assumes you have Kafka and an instance of the REST Proxy running using the default settings and some topics already created.

    # Get a list of topics
    $ curl "http://localhost:8082/topics"
      
      ["__consumer_offsets","jsontest"]

    # Get info about one topic
    $ curl "http://localhost:8082/topics/jsontest"
    
      {"name":"jsontest","configs":{},"partitions":[{"partition":0,"leader":0,"replicas":[{"broker":0,"leader":true,"in_sync":true}]}]}

    # Produce a message with JSON data
    $ curl -X POST -H "Content-Type: application/vnd.kafka.json.v2+json" \
          --data '{"records":[{"value":{"name": "testUser"}}]}' \
          "http://localhost:8082/topics/jsontest"
          
      {"offsets":[{"partition":0,"offset":3,"error_code":null,"error":null}],"key_schema_id":null,"value_schema_id":null}

    # Create a consumer for JSON data, starting at the beginning of the topic's
    # log. The consumer group is called "my_json_consumer" and the instance is "my_consumer_instance".
    
    $ curl -X POST -H "Content-Type: application/vnd.kafka.v2+json" -H "Accept: 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"}
      
    # Subscribe the consumer to a topic
    
    $ 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
    # No content in response
      
    # Then consume some data from a topic using the base URL in the first response.

    $ 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":{"name":"testUser"},"partition":0,"offset":3,"topic":"jsontest"}]
   
    # Finally, close the consumer with a DELETE to make it leave the group and clean up
    # its resources.  
    
    $ curl -X DELETE -H "Accept: application/vnd.kafka.v2+json" \
          http://localhost:8082/consumers/my_json_consumer/instances/my_consumer_instance
      # No content in response

Development

To build a development version, you may need a development versions of common, rest-utils, and schema-registry. After installing these, you can build the Kafka REST Proxy with Maven. All the standard lifecycle phases work.

Contribute

License

The project is licensed under the Apache 2 license.