Avro Schema Registry的价值是什么? [英] What is the value of an Avro Schema Registry?

查看:217
本文介绍了Avro Schema Registry的价值是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多微服务可以在Kafka中读取/写入Avro消息.

I have many microservices reading/writing Avro messages in Kafka.

模式很棒. Avro很棒. 但是真的需要架构注册表吗? ?它可以帮助集中架构,是的,但是微服务真的需要查询注册表吗?我不这么认为.

Schemas are great. Avro is great. But is a schema registry really needed? It helps centralize Schemas, yes, but do the microservices really need to query the registry? I don't think so.

每个微服务都有一个模式副本user.avsc和一个Avro生成的POJO:User extends SpecificRecord.我想要每个Schema的POJO,以便在代码中轻松进行操作.

Each microservice has a copy of the schema, user.avsc, and an Avro-generated POJO: User extends SpecificRecord. I want a POJO of each Schema for easy manipulation in the code.

写给卡夫卡:

byte [] value = user.toByteBuffer().array();
producer.send(new ProducerRecord<>(TOPIC, key, value));

从卡夫卡读书:

User user = User.fromByteBuffer(ByteBuffer.wrap(record.value()));

推荐答案

Schema Registry为您提供了一种方法,使更多的应用程序和服务可以使用数据,而不仅仅是基于Java的微服务.

Schema Registry gives you a way for broader set of applications and services to use the data, not just your Java-based microservices.

例如,您的微服务将数据流式传输到主题,并且您想要将该数据发送到Elasticsearch或数据库.如果您拥有Schema Registry,则可以直接将Kafka Connect连接到该主题,它现在有了该架构,可以创建目标映射或表.如果没有架构注册表,则每个数据使用者都必须以其他方式找出数据架构是什么.

For example, your microservice streams data to a topic, and you want to send that data to Elasticsearch, or a database. If you've got the Schema Registry you literally hook up Kafka Connect to the topic and it now has the schema and can create the target mapping or table. Without a Schema Registry each consumer of the data has to find out some other way what the schema of the data is.

也采取另一种方法-您的微服务想要访问从其他地方(例如,通过Kafka Connect或任何其他生产者)写入到Kafka主题中的数据-使用Schema Registry,您可以轻松地检索架构.没有它,您就开始将微服务开发与必须知道在何处生成源数据及其模式相关联.

Taken the other way around too - your microservice wants to access data that's written into a Kafka topic from elsewhere (e.g. with Kafka Connect, or any other producer) - with the Schema Registry you can simply retrieve the schema. Without it you start coupling your microservice development to having to know about where the source data is being produced and its schema.

这里有一个关于这个主题的好话: https://qconnewyork.com/system/files/presentation-slides/qcon_17_-_schemas_and_apis.pdf

There's a good talk about this subject here: https://qconnewyork.com/system/files/presentation-slides/qcon_17_-_schemas_and_apis.pdf

这篇关于Avro Schema Registry的价值是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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