0

我正在使用 MongoDB Kafka 连接器,我能够成功创建和更新记录,但无法删除连接器配置中的记录我正在使用这个配置

{
"name": "mongo-sink",
"config": {
    "connector.class": "com.mongodb.kafka.connect.MongoSinkConnector",
    "tasks.max": "1",
    "topics": "test",
    "connection.uri": "mongodb://mongo1:27018,mongo2:27019,mongo3:27020",
    "database": "accounting",
    "collection": "test",
    "key.converter": "org.apache.kafka.connect.storage.StringConverter",
    "value.converter": "io.confluent.connect.avro.AvroConverter",
    "value.converter.schema.registry.url": "http://schema-registry:8081",
    "value.converter.schemas.enable": "false",
    "document.id.strategy": "com.mongodb.kafka.connect.sink.processor.id.strategy.PartialKeyStrategy",
    "document.id.strategy.partial.key.projection.list":"productId",
    "document.id.strategy.partial.key.projection.type":"ALLOWLIST",
    "writemodel.strategy":"com.mongodb.kafka.connect.sink.writemodel.strategy.ReplaceOneBusinessKeyStrategy",
    "delete.on.null.values": "true",
    "transforms":"WrapKey",
    "transforms.WrapKey.type":"org.apache.kafka.connect.transforms.HoistField$Key",
    "transforms.WrapKey.field":"_id"
}

}

如果我发送空记录文档更新为空而不删除任何想法,则无法删除记录?

4

1 回答 1

0

MongoDB Sink文档中所述,

删除.on.null.values

布尔值

当值为 null时,连接器是否应删除具有匹配键值的文档。

您必须将消息设置为以下格式:

{"key" : "xyz", "value" : null, ... }
于 2021-01-05T08:26:36.337 回答