官方 MongoDB Kafka 源码连接器不发布 clean extended JSON
The official MongoDB Kafka source connector does not publish clean extended JSON
我设置了一个非常简单的 mongo kafka source connector to stream mongo's oplog to kafka. However, I see that in the messages published by the connector, the serialized oplog events do not respect the extended JSON spec;例如,日期时间字段表示为:
{"$date": 1597841586927}
当规范规定格式应为:
{"$date": {"$numberLong": "1597841586927"}}
为什么我没有得到干净的扩展 JSON?
注意:我的连接器配置文件如下所示:
{
"name": "mongosource",
"config": {
"connector.class": "com.mongodb.kafka.connect.MongoSourceConnector",
"tasks.max": 1,
"connection.uri": "...",
"topic.prefix":"mongosource",
"database": "mydb",
"copy.existing": true,
"change.stream.full.document": "updateLookup",
}
}
源连接器的默认 json 格式化程序是遗留的(请参阅连接器的 JIRA 项目中的 this issue)。
从该连接器的版本 1.3.0
开始,您可以添加一个新的配置选项,以要求连接器输出正确的扩展 JSON:
"output.json.formatter": "com.mongodb.kafka.connect.source.json.formatter.ExtendedJson"
我设置了一个非常简单的 mongo kafka source connector to stream mongo's oplog to kafka. However, I see that in the messages published by the connector, the serialized oplog events do not respect the extended JSON spec;例如,日期时间字段表示为:
{"$date": 1597841586927}
当规范规定格式应为:
{"$date": {"$numberLong": "1597841586927"}}
为什么我没有得到干净的扩展 JSON?
注意:我的连接器配置文件如下所示:
{
"name": "mongosource",
"config": {
"connector.class": "com.mongodb.kafka.connect.MongoSourceConnector",
"tasks.max": 1,
"connection.uri": "...",
"topic.prefix":"mongosource",
"database": "mydb",
"copy.existing": true,
"change.stream.full.document": "updateLookup",
}
}
源连接器的默认 json 格式化程序是遗留的(请参阅连接器的 JIRA 项目中的 this issue)。
从该连接器的版本 1.3.0
开始,您可以添加一个新的配置选项,以要求连接器输出正确的扩展 JSON:
"output.json.formatter": "com.mongodb.kafka.connect.source.json.formatter.ExtendedJson"