简体   繁体   中英

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

I'm using a generic class that gets built depending on the information coming from the DB. 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.

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. We also took the effort to generify the Java class we use to come back to a POJO.

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?

You will need the schema locally, but you can automatically download it during project compilation with the Schema Registry Maven plugin, for example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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