org.apache.avro.AvroTypeException:未知联合分支 refentCodifStdId
org.apache.avro.AvroTypeException: Unknown union branch refentCodifStdId
我正在使用此 avsc 内容:
{
"type" : "record",
"name" : "ReferentialMessageType",
"fields" : [ {
"name" : "type",
"type" : "string"
},
{
"name" : "dictionnaire",
"type" : [ "null", {
"type" : "record",
"name" : "dictionnaireType",
"fields" : [ {
"name" : "refentDictId",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentDictCode",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentDictLibelleCrt",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentDictLibelleLng",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentDictDateFin",
"type" : [ "null", {
"type" : "long",
"logicalType" : "timestamp-millis"
} ],
"default" : null
}, {
"name" : "refentDictPere",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentDictDateDbt",
"type" : [ "null", {
"type" : "long",
"logicalType" : "timestamp-millis"
} ],
"default" : null
} ]
} ],
"default" : null
}, {
"name" : "codification",
"type" : [ "null", {
"type" : "record",
"name" : "codificationType",
"fields" : [ {
"name" : "refentCodifStdId",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentDictId",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentCodifStdCode",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentCodifStdRng",
"type" : [ "null", "double" ],
"default" : null
}, {
"name" : "refentCodifStdLibCrt",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentCodifStdLibLng",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentCodifStdDateDbt",
"type" : [ "null", {
"type" : "long",
"logicalType" : "timestamp-millis"
} ],
"default" : null
}, {
"name" : "refentCodifStdDateFin",
"type" : [ "null", {
"type" : "long",
"logicalType" : "timestamp-millis"
} ],
"default" : null
}, {
"name" : "refentCodifStdPere",
"type" : [ "null", "string" ],
"default" : null
} ]
} ],
"default" : null
} ]
}
并尝试在 kafka 上发布此消息:
{
“类型”:“插入”,
“字典”:空,
“编纂”:{
"refentCodifStdId":"8",
"refentDictId":"2",
"refentCodifStdCode":"AAAA",
"refentCodifStdLibCrt":"BBBB",
“refentCodifStdPere”:“2”
}
}
但是我收到以下错误:
org.apache.avro.AvroTypeException: Unknown union branch refentCodifStdId
at org.apache.avro.io.JsonDecoder.readIndex(JsonDecoder.java:434)
at org.apache.avro.io.ResolvingDecoder.readIndex(ResolvingDecoder.java:282)
at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:187)
at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:160)
at org.apache.avro.generic.GenericDatumReader.readField(GenericDatumReader.java:259)
at org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:247)
at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:179)
at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:160)
at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:153)
at org.akhq.modules.AvroSerializer.fromJsonToAvro(AvroSerializer.java:63)
at org.akhq.modules.AvroSerializer.toAvro(AvroSerializer.java:48)
at org.akhq.repositories.RecordRepository.produce(RecordRepository.java:528)
at org.akhq.controllers.TopicController.produce(TopicController.java:141)
at org.akhq.controllers.$TopicControllerDefinition$$exec4.invokeInternal(Unknown Source)
能否请您帮忙了解一下哪里出了问题?
此致
我认为您需要像下面这样的 JSON,以便为联合字段显式调出类型:
{
"type": "insert",
"dictionnaire": null,
"codification": {
"codificationType": {
"refentCodifStdId": {
"string": "8"
},
"refentDictId": {
"string": "2"
},
"refentCodifStdCode": {
"string": "AAAA"
},
"refentCodifStdLibCrt": {
"string": "BBBB"
},
"refentCodifStdPere": {
"string": "2"
}
}
}
}
我正在使用此 avsc 内容:
{
"type" : "record",
"name" : "ReferentialMessageType",
"fields" : [ {
"name" : "type",
"type" : "string"
},
{
"name" : "dictionnaire",
"type" : [ "null", {
"type" : "record",
"name" : "dictionnaireType",
"fields" : [ {
"name" : "refentDictId",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentDictCode",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentDictLibelleCrt",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentDictLibelleLng",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentDictDateFin",
"type" : [ "null", {
"type" : "long",
"logicalType" : "timestamp-millis"
} ],
"default" : null
}, {
"name" : "refentDictPere",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentDictDateDbt",
"type" : [ "null", {
"type" : "long",
"logicalType" : "timestamp-millis"
} ],
"default" : null
} ]
} ],
"default" : null
}, {
"name" : "codification",
"type" : [ "null", {
"type" : "record",
"name" : "codificationType",
"fields" : [ {
"name" : "refentCodifStdId",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentDictId",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentCodifStdCode",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentCodifStdRng",
"type" : [ "null", "double" ],
"default" : null
}, {
"name" : "refentCodifStdLibCrt",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentCodifStdLibLng",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "refentCodifStdDateDbt",
"type" : [ "null", {
"type" : "long",
"logicalType" : "timestamp-millis"
} ],
"default" : null
}, {
"name" : "refentCodifStdDateFin",
"type" : [ "null", {
"type" : "long",
"logicalType" : "timestamp-millis"
} ],
"default" : null
}, {
"name" : "refentCodifStdPere",
"type" : [ "null", "string" ],
"default" : null
} ]
} ],
"default" : null
} ]
}
并尝试在 kafka 上发布此消息:
{ “类型”:“插入”, “字典”:空, “编纂”:{ "refentCodifStdId":"8", "refentDictId":"2", "refentCodifStdCode":"AAAA", "refentCodifStdLibCrt":"BBBB", “refentCodifStdPere”:“2” } }
但是我收到以下错误:
org.apache.avro.AvroTypeException: Unknown union branch refentCodifStdId
at org.apache.avro.io.JsonDecoder.readIndex(JsonDecoder.java:434)
at org.apache.avro.io.ResolvingDecoder.readIndex(ResolvingDecoder.java:282)
at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:187)
at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:160)
at org.apache.avro.generic.GenericDatumReader.readField(GenericDatumReader.java:259)
at org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:247)
at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:179)
at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:160)
at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:153)
at org.akhq.modules.AvroSerializer.fromJsonToAvro(AvroSerializer.java:63)
at org.akhq.modules.AvroSerializer.toAvro(AvroSerializer.java:48)
at org.akhq.repositories.RecordRepository.produce(RecordRepository.java:528)
at org.akhq.controllers.TopicController.produce(TopicController.java:141)
at org.akhq.controllers.$TopicControllerDefinition$$exec4.invokeInternal(Unknown Source)
能否请您帮忙了解一下哪里出了问题?
此致
我认为您需要像下面这样的 JSON,以便为联合字段显式调出类型:
{
"type": "insert",
"dictionnaire": null,
"codification": {
"codificationType": {
"refentCodifStdId": {
"string": "8"
},
"refentDictId": {
"string": "2"
},
"refentCodifStdCode": {
"string": "AAAA"
},
"refentCodifStdLibCrt": {
"string": "BBBB"
},
"refentCodifStdPere": {
"string": "2"
}
}
}
}