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

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

问题描述

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

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

架构很棒.阿罗很棒.但是真的需要架构注册表吗?它有助于集中架构,是的,但是微服务真的需要查询注册表吗?我不这么认为.

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 主题的数据(例如使用 Kafka Connect,或任何其他生产者) - 使用 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天全站免登陆