向融合模式注册注册AVRO模式 [英] Registering AVRO schema with confluent schema registery

查看:115
本文介绍了向融合模式注册注册AVRO模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以将AVRO模式注册到融合模式注册服务吗?

Can AVRO schemas be registered with confluent schema registry service ?

根据github
上的自述文件 https://github.com/confluentinc/schema-registry

每个示例都使用具有单个字段和类型且没有任何名称的JSON模式。

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"}]}"}' 

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


推荐答案

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

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 

您缺少一些参数。

您可以使用SchemaRegistryHelper获取任何ID的模式以反序列化数据。

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

这篇关于向融合模式注册注册AVRO模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆