Apache kafka 架构注册表-注册自定义对象类型

Apache kafka 架构注册表-注册自定义对象类型,apache-kafka,avro,confluent-schema-registry,Apache Kafka,Avro,Confluent Schema Registry,我想注册一个Avro模式,它引用模式注册表上的另一个Avro模式 首先,我注册了以下基本Avro模式: { "type":"record", "name":"Client", "namespace":"com.test.client", "doc": "Client Property specific information is

我想注册一个Avro模式,它引用模式注册表上的另一个Avro模式

首先,我注册了以下基本Avro模式:

{
  "type":"record",
  "name":"Client",
  "namespace":"com.test.client",
  "doc": "Client Property specific information is specified in this object",
  "fields" : [
      {"name" : "name", "type" : [ "null", "string" ]},
      {"name" : "address", "type" :  [ "null", "string"]}
  ]
}
如果我尝试注册以下Avro模式,该模式引用“client”属性中的基本模式,则操作将失败,并出现错误422


{
  "type":"record",
  "name":"AnotherObject",
  "namespace":"com.test.client",
  "fields":
  [
    {"name":"tenant", "type": [ "null", "long" ]},
    {"name":"client", "type" : [ "null","com.test.client.Client"]}
  ]
}
这个问题似乎与指定自定义类型字段有关


您知道如何在架构注册表中注册相关架构时添加自定义类型吗?

您可以使用架构引用让架构引用合流架构注册表中的其他架构

请注意,对这种表示法的支持是在 汇合平台5.5

根据您的示例(根据上提供的文档),您应该在新模式注册的POST请求中使用以下有效负载注册另一个对象:

{
  "schema":"{
     \"type\":\"record\",
     \"name\":\"AnotherObject\",
     \"namespace\":\"com.test.client\",
     \"fields\":[
        {
           \"name\":\"tenant\",
           \"type\":[\"null\",\"long\"]
        },
        {
           \"name\":\"client\",
           \"type\":[\"null\",\"com.test.client.Client\"]
        }
     ]
   }",
  "schemaType":"AVRO",
  "references":[
    {
      "name":"com.test.client.Client",
      "subject":"clientSubject",
      "version":1
    }
  ]
}
其中,clientSubject是您在注册
com.test.client.client
架构时指定的主题名称

正如您可以看到的,基本上通过这种方法,您可以直接指定要使用的引用模式的版本。这非常有用,因为否则可能会出现不一致


在下面的链接中查看文档以获取关于模式引用的更多信息:

理想情况下,您可以嵌套完整的对象,但我知道引用最近添加到了API中。这正是我想要的