【发布时间】:2020-08-26 11:02:23
【问题描述】:
我正在尝试发布一条消息,其中包含一个字段的联合
{
"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
我在这里缺少什么?任何解决问题的指针都非常感谢。
【问题讨论】:
标签: spring-boot apache-kafka avro confluent-platform confluent-schema-registry