我们正在开发中,并试图删除主题的架构,因为更改与旧架构不兼容。
我们删除了架构/主题,并尝试使用相同的主题名称创建新架构,并且架构已成功创建。
但是,当我们运行该应用程序时,它仍然指向相同的架构ID。
旧模式ID(针对主题“ topic1”):51
新的模式ID(针对主题“ topic1”):52
应用程序失败,并出现反序列化消息的错误
at org.apache.kafka.streams.processor.internals.StreamThread.run(StreamThread.java:736)
Caused by: org.apache.kafka.common.errors.SerializationException: Error deserializing Avro message for id 51
Caused by: org.apache.avro.AvroTypeException: Found string, expecting union
at org.apache.avro.io.ResolvingDecoder.doAction(ResolvingDecoder.java:292)
at org.apache.avro.io.parsing.Parser.advance(Parser.java:88)
at org.apache.avro.io.ResolvingDecoder.readIndex(ResolvingDecoder.java:267)
at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumRea
root@bas:/# curl -k https://schemaregistry:443/subjects/topic1/versions/latest
{"subject":"topic1","version":15,"id":52,"schema":"{\"type\":\"record\",\"name\":\"TopicOutputOutput\",\"namespace\":\"com.sagar.avsc\",\"fields\":[{\"name\":\"id\",\"type\":\"long\"},{\"name\":\"client\",\"type\":{\"type\":\"record\",\"name\":\"ClientObject\",\"fields\":[{\"name\":\"name\",\"type\":[\"null\",\"string\"]},{\"name\":\"client_id\",\"type\":[\"null\",\"long\"]},{\"name\":\"source_system_id\",\"type\":[\"null\",\"long\"]}]}}, ...
更改:
{\"name\":\"client_id\",\"type\":[\"null\",\"long\"]}
您可以看到模式ID为52,但是应用程序正在尝试使用较早的模式ID(51),该模式ID与我们发送的数据不兼容
root@bas:/# curl -k https://schemaregistry:443/schemas/ids/52
{"schema":"{\"type\":\"record\",\"name\":\"TopicOutputOutput\",\"namespace\":\"com.sagar.avsc\",\"fields\":[{\"name\":\"id\",\"type\":\"long\"},{\"name\":\"client\",\"type\":{\"type\":\"record\",\"name\":\"ClientObject\",\"fields\":[{\"name\":\"name\",\"type\":[\"null\",\"string\"]},{\"name\":\"client_id\",\"type\":[\"null\",\"long\"]},{\"name\":\"source_system_id\",
更改:
{\"name\":\"name\",\"type\":[\"null\",\"string\"]}
为什么应用程序仍引用旧的模式ID?有没有办法删除模式ID?
答案 0 :(得分:0)
您可以向/subjects/:name/versions/:version
发出DELETE
但是,模式ID 51仍然是主题中的 ,在这些特定的消息到期之前,或者在压缩主题的情况下,它们已经成为逻辑删除,无法从那里删除它。
如果架构不兼容,那么我将检查注册表的配置,因为默认情况下,它不允许向后不兼容的更改。