在模式注册中,消费者的模式可能与生产者的不同,这实际上意味着什么 [英] In schema registry, consumer's schema could differ from the producer's, what actually it means

查看:35
本文介绍了在模式注册中,消费者的模式可能与生产者的不同,这实际上意味着什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在向 Kafka 生成 AVRO 数据时,Avro 序列化程序在写入数据时使用的字节数组中写入相同的模式 ID.

While producing AVRO data to Kafka, Avro serializer writing the same schema ID in the byte array which is used while writing the data.

Kafka 消费者根据收到的字节数组中的架构 ID 从架构注册表中获取架构.所以相同的架构 ID 用于生产者和消费者等架构中.

Kafka Consumer fetches the schema from Schema Registry based on schema ID in the byte array received. So same schema ID is used in both i.e. Producer and Consumer and so the schema.

但是为什么很多文章包括这个one消费者的模式可能与生产者的不同.

But why many article including this one says The consumer's schema could differ from the producer's.

请帮助我理解这一点.

推荐答案

Kafka 消费者根据架构 ID 从架构注册表中获取架构

Kafka Consumer fetches the schema from Schema Registry based on schema ID

仅当您让解串器执行此操作时.

Only if you let the deserializer do that.

您可以在消费者代码中定义自己的兼容架构.因此,它可以不同并遵循Avro模式演化的规则

You're capable of defining your own, compatible schema in the consumer code. Therefore, it could be different and follows the rules of Avro schema evolution

模式演变仅在消费者反序列化期间发生(读取).如果消费者的架构与生产者的架构不同,则反序列化期间会自动修改值或键,以尽可能符合消费者的读取架构.

schema evolution happens only during deserialization at the consumer (read). If the consumer’s schema is different from the producer’s schema, then the value or key is automatically modified during deserialization to conform to the consumer's read schema if possible.

这篇关于在模式注册中,消费者的模式可能与生产者的不同,这实际上意味着什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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