将avro有效负载发布到kafka rest服务时,如果value\u schema中的某个字段使用默认值定义,则在记录中省略该字段。Kafka似乎还坚持要把它记录在案。正确的方法是什么?
如。
curl -X POST -H "Content-Type: application/vnd.kafka.avro.v1+json" \
--data '{"value_schema": "{\"type\": \"record\", \"name\": \"User\", \"fields\": [{\"name\": \"name\", \"type\": \"string\"}, {\"name\":\"age\",\"type\":\"int\",\"default\":18}, {\"name\":\"id\",\"type\":\"string\"}]}", "records": [{"value": {"name": "testUser", "id": "001"}}]}' \
"http://localhost:8082/topics/avrotest"
输出
{"error_code":42203,"message":"Conversion of JSON to Avro failed: Failed to convert JSON to Avro: Expected field name not found: age"}
暂无答案!
目前还没有任何答案,快来回答吧!