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

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

问题描述

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

Can AVRO schemas be registered with confluent schema registry service ?

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

As per readme on 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天全站免登陆