【发布时间】:2020-01-25 15:14:08
【问题描述】:
我们正在开发并尝试删除主题的架构,因为更改与旧架构不兼容。
我们删除了架构/主题并尝试在相同的主题名称下创建新架构,并且架构已成功创建。
但是,当我们运行应用程序时,它仍然指向相同的架构 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),这与我们发送的数据不兼容
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 ?有没有办法删除 Schema ID ?
【问题讨论】:
标签: apache-kafka avro confluent-schema-registry confluent-platform