以架构类型作为对象的反序列化Avro消息

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

我正在阅读包含Avro消息的Kafka主题。我已经给出了以下架构。我无法解析架构并反序列化消息。

{"type": "record",
"name": "Request",
"namespace": "com.sk.avro.model",
"fields": [
{
  "name": "jobId",
  "type": [
    "null",
    "string"
  ],
  "default": null,
  "description": "REQUIRED "
},
{
  "name": "businessUnit",
  "type": "com.example.BusinessUnit",
  "default": "ABC",
  "description": "Business id"
}
}

我遇到错误:

The type of the "businessUnit" field must be a defined name or a {"type": ...} expression

任何人都可以帮忙。

apache-kafka deserialization kafka-consumer-api avro
1个回答
0
投票

怎么样

{
    "name": "businessUnit",
    "type": { 
        "type ": { 
            "type ": "record ", 
            "name ": "BusinessUnit ", 
            "fields ": [{ 
                "name ": "hostName ", 
                "type ": "string " 
             }] 
         } 
     } 
 }
© www.soinside.com 2019 - 2024. All rights reserved.