Spring boot 使用Kafka REST Proxy抛出发布Avro消息;将JSON转换为Avro失败”;
我正试图发布一条消息,其中一个字段的联合为Spring boot 使用Kafka REST Proxy抛出发布Avro消息;将JSON转换为Avro失败”;,spring-boot,apache-kafka,avro,confluent-platform,confluent-schema-registry,Spring Boot,Apache Kafka,Avro,Confluent Platform,Confluent Schema Registry,我正试图发布一条消息,其中一个字段的联合为 { "name": "somefield", "type": [ "null", { "type": "array", "items": { "type": "record", 当somefield填充了一个数组时,使用Kafka REST代理发布消息会不断引发以下错误 { "error_code": 42203, "message": "Conversion of JSON t
{
"name": "somefield",
"type": [
"null",
{
"type": "array",
"items": {
"type": "record",
当somefield
填充了一个数组时,使用Kafka REST代理发布消息会不断引发以下错误
{
"error_code": 42203,
"message": "Conversion of JSON to Avro failed: Failed to convert JSON to Avro: Expected start-union. Got START_ARRAY"
}
使用somefield:null
的相同架构工作正常
Java类是使用来自Avro模式的gradle插件在Spring Boot项目中构建的。当我使用生成的Java类并发布消息时,使用Spring KafkaTemplate填充数组,消息将使用正确的模式正确发布。(模式取自生成的Avro特定记录)我复制了相同的json值和模式,并通过REST代理发布,它失败了,出现上述错误
我在API调用中有这些内容类型
accept:application/vnd.kafka.v2+json, application/vnd.kafka+json, application/json
content-type:application/vnd.kafka.avro.v2+json
我错过了什么?非常感谢您提供任何解决问题的建议。我测试的消息是
{
"somefield" : null
}
及
但是,它应该作为
{
"somefield" : {
"array": [
{"field1": "hello"}
]}
}
{
"somefield" : {
"array": [
{"field1": "hello"}
]}
}