Kafka 架构注册表的架构问题
Schema issue with Kafka schema registry
我知道我是带着任何消息来找你的,但我一直在解决一个可能是我的错的问题,事实上我不知道解决方案是什么。
我使用独立安装的 Confluent 平台(4.0.0 开源版本)来演示如何针对特定用例采用该平台。
试图证明使用架构注册表的价值我在使用 Postman 发布新架构时遇到了以下问题。
请求是:
http://host:8081/subjects/test/versions
, method POST
, Header: Accept:application/vnd.schemaregistry.v1+json, application/vnd.schemaregistry+json, application/json
Content-Type:application/json
, Body:
{"schema":"{{\"namespace\":\"com.testlab\",\"name\":\"test\",\"type\":\"record\",\"fields\":[{\"name\":\"resourcepath\",\"type\":\"string\"},{\"name\":\"resource\",\"type\":\"string\"}]}}" }
响应是:{"error_code":42201,"message":"Input schema is an invalid Avro schema"}
查看文档并在谷歌上搜索了很多之后我没有选择。
有什么建议吗?
谢谢你的时间
R.
您在架构字段周围有额外的 {}
。
一种测试方法是 jq
之前
$ echo '{"schema":"{{\"namespace\":\"com.testlab\",\"name\":\"test\",\"type\":\"record\",\"fields\":[{\"name\":\"resourcepath\",\"type\":\"string\"},{\"name\":\"resource\",\"type\":\"string\"}]}}" }' | jq '.schema|fromjson'
jq: error (at <stdin>:1): Objects must consist of key:value pairs at line 1, column 146 (while parsing '{{"namespace":"com.testlab","name":"test","type":"record","fields":[{"name":"resourcepath","type":"string"},{"name":"resource","type":"string"}]}}')
之后
$ echo '{"schema":"{\"namespace\":\"com.testlab\",\"name\":\"test\",\"type\":\"record\",\"fields\":[{\"name\":\"resourcepath\",\"type\":\"string\"},{\"name\":\"resource\",\"type\":\"string\"}]}" }' | jq '.schema|fromjson'
{
"namespace": "com.testlab",
"name": "test",
"type": "record",
"fields": [
{
"name": "resourcepath",
"type": "string"
},
{
"name": "resource",
"type": "string"
}
]
}
请参阅 my comment here 关于导入 AVSC 文件,这样您就不需要在 CLI 上输入 JSON
我知道我是带着任何消息来找你的,但我一直在解决一个可能是我的错的问题,事实上我不知道解决方案是什么。 我使用独立安装的 Confluent 平台(4.0.0 开源版本)来演示如何针对特定用例采用该平台。 试图证明使用架构注册表的价值我在使用 Postman 发布新架构时遇到了以下问题。
请求是:
http://host:8081/subjects/test/versions
, method POST
, Header: Accept:application/vnd.schemaregistry.v1+json, application/vnd.schemaregistry+json, application/json
Content-Type:application/json
, Body:
{"schema":"{{\"namespace\":\"com.testlab\",\"name\":\"test\",\"type\":\"record\",\"fields\":[{\"name\":\"resourcepath\",\"type\":\"string\"},{\"name\":\"resource\",\"type\":\"string\"}]}}" }
响应是:{"error_code":42201,"message":"Input schema is an invalid Avro schema"}
查看文档并在谷歌上搜索了很多之后我没有选择。 有什么建议吗? 谢谢你的时间 R.
您在架构字段周围有额外的 {}
。
一种测试方法是 jq
之前
$ echo '{"schema":"{{\"namespace\":\"com.testlab\",\"name\":\"test\",\"type\":\"record\",\"fields\":[{\"name\":\"resourcepath\",\"type\":\"string\"},{\"name\":\"resource\",\"type\":\"string\"}]}}" }' | jq '.schema|fromjson'
jq: error (at <stdin>:1): Objects must consist of key:value pairs at line 1, column 146 (while parsing '{{"namespace":"com.testlab","name":"test","type":"record","fields":[{"name":"resourcepath","type":"string"},{"name":"resource","type":"string"}]}}')
之后
$ echo '{"schema":"{\"namespace\":\"com.testlab\",\"name\":\"test\",\"type\":\"record\",\"fields\":[{\"name\":\"resourcepath\",\"type\":\"string\"},{\"name\":\"resource\",\"type\":\"string\"}]}" }' | jq '.schema|fromjson'
{
"namespace": "com.testlab",
"name": "test",
"type": "record",
"fields": [
{
"name": "resourcepath",
"type": "string"
},
{
"name": "resource",
"type": "string"
}
]
}
请参阅 my comment here 关于导入 AVSC 文件,这样您就不需要在 CLI 上输入 JSON