Debezium可能会产生无效的架构

问题描述 投票:0回答:1

我遇到Avro和Schema Registry的问题。在Debezium创建架构和主题之后,我从Schema Registry下载了该架构。我把它放到一个.asvc文件中,它看起来像这样:

  {
    "type": "record",
    "name": "Envelope",
    "namespace": "my.namespace",
    "fields": [
      {
        "name": "before",
        "type": [
          "null",
          {
            "type": "record",
            "name": "MyValue",
            "fields": [
              {
                "name": "id",
                "type": "int"
              }
            ]
          }
        ],
        "default": null
      },
      {
        "name": "after",
        "type": [
          "null",
          "MyValue"
        ],
        "default": null
      }
    ]
  }

我进行了两个实验:

  1. [我试图将其放回架构注册表,但出现此错误:MyValue不正确。当我删除“之后”记录时,该架构似乎运行良好。

  2. [我使用了avro-maven-plugin中的'generate-sources'来生成Java类。当我尝试使用上述主题时,会看到此错误:

    线程“ b2-StreamThread-1”中的异常org.apache.kafka.streams.errors.StreamsException:进程中捕获了异常。 [...]:注册Avro模式时出错:[...]

    原因:io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException:正在注册的架构与早期的架构不兼容;错误代码:409

有人遇到过同样的问题吗?是Debezium生成了无效的架构,还是Schema Registry出现了错误?

apache-kafka avro confluent-schema-registry debezium
1个回答
0
投票

MyValue不正确。

这不是Avro类型。您必须将实际记录嵌入联合中,就像之前的值

换句话说,您不能交叉引用架构中的记录类型,即AFAIK

[当我尝试使用上述主题时,我看到此错误:

使用者没有注册模式,因此除非可能使用Kafka Streams(会产生中间主题,否则不清楚)如何得到该错误

© www.soinside.com 2019 - 2024. All rights reserved.