我想使用 Postman 将 json 发送到 Kafka 主题。
在邮递员中,当发送以下 json 时一切正常(kafka 没有返回错误,并且在使用主题时我可以看到正确的值):
{
"records": [
{
"key":"some_key",
"value":"test"
}
]
}
但是,当发送以下带有 aschema
和payload
嵌入的 json 时:
{
"schema": {
"type": "struct",
"fields": [
{
"type": "string",
"optional": false,
"field": "userid"
},
{
"type": "string",
"optional": false,
"field": "regionid"
},
{
"type": "string",
"optional": false,
"field": "gender"
}
],
"optional": false,
"name": "ksql.users"
},
"payload": {
"userid": "User_1",
"regionid": "Region_5",
"gender": "MALE"
}
}
我得到以下答案:
{
"error_code": 422,
"message": "Unrecognized field: schema"
}
以下来源建议嵌入模式,因为 JDBC 接收器需要它: https://github.com/confluentinc/kafka-connect-jdbc/issues/609 https://www.confluent.io/blog/kafka -connect-deep-dive-converters-serialization-explained/
在我的sink-postgresql.properties
我设置:
value.converter=org.apache.kafka.connect.json.JsonConverter
value.converter.shemas.enable=true
key.converter.shemas.enable=true
key.converter=org.apache.kafka.connect.json.JsonConverter
我不知道为什么到目前为止它不起作用,一些帮助可能会有用。
系统:Ubuntu 18.04 confluent-platform postman 7.14