0

Can AVRO schemas be registered with confluent schema registry service ?

As per readme on github https://github.com/confluentinc/schema-registry

Every example uses a JSON schema with a single field and type without any name.

I am trying to store following schema to repository but with different variants getting different error.

curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" --data '{"schema": "{"type": "record","name": "myrecord","fields": [{"name": "serialization","type": "string"},{"name": "compression","type": "string"},{"name": "encoding","type": "string"},{"name": "data","type": "string"}]}"}' 

Or

curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" --data '{"schema": \"{\"type\": \"record\",\"name\": \"myrecord\",\"fields\": [{\"name\": \"data\",\"type\": \"string\"}]}\"}' http://localhost:8081/subjects/Kafka-key/versions
4

1 回答 1

2

可以使用以下命令使用 kafka 注册 Avro 模式

curl -X POST -i -H "Content-Type: application/vnd.schemaregistry.v1+json" --data '{"schema": "{\"type\": \"record\",\"name\": \"myrecord\",\"fields\": [{\"name\": \"serialization\",\"type\": \"string\"},{\"name\": \"compression\",\"type\": \"string\"},{\"name\": \"encoding\",\"type\": \"string\"},{\"name\": \"data\",\"type\": \"string\"}]}"}' http://localhost:8081/subjects/Kafka-key/versions 

您缺少一些参数。

您可以使用 SchemaRegistryHelper 获取任何 id 的架构以反序列化数据。

于 2017-09-04T11:56:25.463 回答