Registering AVRO schema with confluent schema registery

元气小坏坏 提交于 2019-12-25 04:34:20

问题


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

回答1:


Avro schema can be registered using kafka using below command

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 

You are missing some params.

You can use SchemaRegistryHelper to get schema for any id to deserialize data.



来源:https://stackoverflow.com/questions/40728056/registering-avro-schema-with-confluent-schema-registery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!