Kafka Connect JDBC 接收器连接器
Kafka Connect JDBC Sink Connector
我正在尝试将主题(json 数据)中的数据写入 MySql 数据库。我相信我想要一个 JDBC 接收器连接器。
如何配置连接器以将主题中的 json 数据映射到如何将数据插入数据库。
我能找到的唯一文档是这个。
"The sink connector requires knowledge of schemas, so you should use a
suitable converter e.g. the Avro converter that comes with Schema
Registry, or the JSON converter with schemas enabled. Kafka record
keys if present can be primitive types or a Connect struct, and the
record value must be a Connect struct. Fields being selected from
Connect structs must be of primitive types. If the data in the topic
is not of a compatible format, implementing a custom Converter may be
necessary."
但是你是怎么配置的呢?有例子吗?
I assume that means you need to use Confluent Schema Registry?
对于 "better" 架构支持,是的。但不,这不是必需的。
您可以将 JsonConverter 与 schemas.enable=true
一起使用
您的 JSON 消息需要看起来像这样,
{
"schema" : {
... data that describes the payload
},
"payload": {
... your actual data
}
}
关于这个格式的参考,可以看this blog
您可以使用 Kafka Streams or KSQL 更轻松地将 "schemaless" JSON 转换为 schema-d Avro 负载
我正在尝试将主题(json 数据)中的数据写入 MySql 数据库。我相信我想要一个 JDBC 接收器连接器。
如何配置连接器以将主题中的 json 数据映射到如何将数据插入数据库。
我能找到的唯一文档是这个。
"The sink connector requires knowledge of schemas, so you should use a suitable converter e.g. the Avro converter that comes with Schema Registry, or the JSON converter with schemas enabled. Kafka record keys if present can be primitive types or a Connect struct, and the record value must be a Connect struct. Fields being selected from Connect structs must be of primitive types. If the data in the topic is not of a compatible format, implementing a custom Converter may be necessary."
但是你是怎么配置的呢?有例子吗?
I assume that means you need to use Confluent Schema Registry?
对于 "better" 架构支持,是的。但不,这不是必需的。
您可以将 JsonConverter 与 schemas.enable=true
您的 JSON 消息需要看起来像这样,
{
"schema" : {
... data that describes the payload
},
"payload": {
... your actual data
}
}
关于这个格式的参考,可以看this blog
您可以使用 Kafka Streams or KSQL 更轻松地将 "schemaless" JSON 转换为 schema-d Avro 负载