KafkaIQ

10.9.4 – Consuming Messages via REST

Module: Section 10 – Kafka Ecosystem & Tools
Section: 10.9 – Kafka REST Proxy
Goal: Consume messages from Kafka via REST API


Step 1: Create Consumer Instance

curl -X POST http://localhost:8082/consumers/my-consumer-group \
  -H "Content-Type: application/vnd.kafka.v2+json" \
  -d '{
    "name": "my-consumer-instance",
    "format": "json",
    "auto.offset.reset": "earliest"
  }'

Response:

{
  "instance_id": "my-consumer-instance",
  "base_uri": "http://localhost:8082/consumers/my-consumer-group/instances/my-consumer-instance"
}

Step 2: Subscribe to Topics

curl -X POST http://localhost:8082/consumers/my-consumer-group/instances/my-consumer-instance/subscription \
  -H "Content-Type: application/vnd.kafka.v2+json" \
  -d '{"topics": ["orders"]}'

Step 3: Poll for Messages

curl -X GET http://localhost:8082/consumers/my-consumer-group/instances/my-consumer-instance/records \
  -H "Accept: application/vnd.kafka.json.v2+json"

Response:

[
  {
    "topic": "orders",
    "key": "order-1",
    "value": {"orderId": "12345", "amount": 99.99},
    "partition": 0,
    "offset": 12345
  }
]

Step 4: Delete Consumer Instance

curl -X DELETE http://localhost:8082/consumers/my-consumer-group/instances/my-consumer-instance

Key Takeaways

  1. Create Instance: POST /consumers/{group}
  2. Subscribe: POST .../subscription
  3. Poll: GET .../records
  4. Delete: DELETE .../instances/{instance}

What's Next?

Next Module: 10.9.5 – Serialization & Schema Registry with REST