0

I am trying to connect a running redpanda kafka cluster to a redpanda schema registry, so that the schema registry verifies incoming messages to the topic, and/or messages being read from the topic.

I am able to add a schema to the registry and read it back with curl requests, as well as add messages to the kafka topic I created in the redpanda cluster.

My question is, how to implement the schema registry with a topic in a kafka cluster? Like how do I instruct the schema registry and/or the kafka topic to validate incoming messages against the schema I added to the registry?

Thanks for your help or a point in the right direction!

Relevant info:

Cluster & topic creation: https://vectorized.io/docs/guide-rpk-container

rpk container start -n 3
rpk topic create -p 6 -r 3 new-topic --brokers <broker1_address>,<broker2_address>...

Schema Registry creation: https://vectorized.io/blog/schema_registry/

Command to add a schema:

curl -s \
  -X POST \
  "http://localhost:8081/subjects/sensor-value/versions" \
  -H "Content-Type: application/vnd.schemaregistry.v1+json" \
  -d '{"schema": "{\"type\":\"record\",\"name\":\"sensor_sample\",\"fields\":[{\"name\":\"timestamp\",\"type\":\"long\",\"logicalType\":\"timestamp-millis\"},{\"name\":\"identifier\",\"type\":\"string\",\"logicalType\":\"uuid\"},{\"name\":\"value\",\"type\":\"long\"}]}"}' \
  | jq
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Andrew Smith
  • 483
  • 1
  • 3
  • 16

1 Answers1

1

The client is responsible for such integration. For example, the Confluent Schema Registry includes KafkaAvroSerializer Java class that wraps an HTTP Client that handles the schema registration and message validation. The broker doesn't handle "topic schemas", since schemas are really per-record. Unless RedPanda has something similar, broker-side validation is only offered by Enterprise "Confluent Server."

RedPanda is primarily a server that exposes a Kafka-compatible API; I assume it is up to you to create (de)serializer interfaces for your respective client languages. There is a Python example on Vectorized Github.
That being said, the Confluent Schema Registry should work with RedPanda as well, and so you can use its serializers and HTTP client libraries with it.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • Thanks for the helpful response. I will be looking into how to use Confluent's serializers and HTTP client libraries, as I am working with a Confluent cluster and schema registry container now. Good to know about the Enterprise offering too, as I am in an enterprise environment and once we are in prod that could be an option. – Andrew Smith Jan 12 '22 at 17:30