简体   繁体   English

JSON Schema + Schema registry + Kafka序列化

[英]JSON Schema + Schema registry + Kafka serialization

I'm trying to use JSON Schema with Kafka following https://docs.confluent.io/platform/current/schema-registry/serdes-develop/serdes-json.html#json-schema-serializer-and-deserializer我正在尝试在 https 之后使用 JSON Schema 和 Kafka ://docs.confluent.io/platform/current/schema-registry/serdes-develop/serdes-json.html#json-schema-serializer-and-deserializer

I'm using a generic class that gets built depending on the information coming from the DB.我使用的是根据来自数据库的信息构建的通用 class。 In that link there are 2 ways to serialize a message, to have a POJO class to derive the schema from it or to pass the schema directly to the producer using the @Schema annotation on a java class.在该链接中,有两种方法可以序列化消息,使用 POJO class 从中派生模式,或者使用 java class 上的 @Schema 注释将模式直接传递给生产者。

I'm storing the JSON schema on the confluent schema registry, so it doesn't make any sense to also have the schema hardcoded in the repository for serializing purposes.我将 JSON 模式存储在汇合模式注册表中,因此将模式硬编码到存储库中以进行序列化没有任何意义。 We also took the effort to generify the Java class we use to come back to a POJO.我们还努力生成我们用来返回 POJO 的 Java class。

Is there any way to use the schema fetched from the schema repository and use generic types, avoiding the use of POJOs with the same properties as the schema and plugins like jsonschema2pojo to send a message with Kafka?有什么方法可以使用从模式存储库中获取的模式并使用泛型类型,避免使用与模式和插件(如 jsonschema2pojo)具有相同属性的 POJO 来使用 Kafka 发送消息?

You will need the schema locally, but you can automatically download it during project compilation with the Schema Registry Maven plugin, for example.您将在本地需要该架构,但您可以在项目编译期间使用架构注册表 Maven 插件自动下载它,例如。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM