KafkaIQ

10.9.5 – Serialization & Schema Registry with REST

Module: Section 10 – Kafka Ecosystem & Tools
Section: 10.9 – Kafka REST Proxy
Goal: Use Avro and Schema Registry with REST Proxy


Producer with Avro

curl -X POST http://localhost:8082/topics/users \
  -H "Content-Type: application/vnd.kafka.avro.v2+json" \
  -d '{
    "value_schema": "{\"type\":\"record\",\"name\":\"User\",\"fields\":[{\"name\":\"userId\",\"type\":\"long\"},{\"name\":\"username\",\"type\":\"string\"}]}",
    "records": [
      {
        "value": {"userId": 123, "username": "alice"}
      }
    ]
  }'

REST Proxy automatically registers schema with Schema Registry


Consumer with Avro

# Create consumer with Avro format
curl -X POST http://localhost:8082/consumers/my-group \
  -d '{"name": "my-consumer", "format": "avro"}'

# Poll messages (automatically deserializes Avro)
curl -X GET http://localhost:8082/consumers/my-group/instances/my-consumer/records \
  -H "Accept: application/vnd.kafka.avro.v2+json"

Schema Registry Integration

REST Proxy Configuration:

schema.registry.url=http://localhost:8081

Automatic schema registration and retrieval


Key Takeaways

  1. Avro Format: application/vnd.kafka.avro.v2+json
  2. value_schema: Provide inline or use Schema Registry
  3. Automatic: REST Proxy handles schema registration
  4. Configuration: Point REST Proxy to Schema Registry

What's Next?

Next Module: 10.10 – REST Proxy Operations & Ecosystem Tools