简体   繁体   English

我们如何将多个集合映射到 mongodb-sink-connector 中的多个主题?

[英]How do we map multiple collections to multiple topics in the mongodb-sink-connector?

I am using a mongodb sink connector to read from some topics json data, and then write them into their respective collections in mongodb.我正在使用 mongodb sink 连接器从一些主题 json 数据中读取,然后将它们写入它们在 mongodb 中各自的集合中。 But, when I give multiple collections with topic-collection mappings, the connector doesn't recognize the collection names, and instead create collections with the name same as the topics'.但是,当我使用主题-集合映射提供多个集合时,连接器无法识别集合名称,而是创建名称与主题相同的集合。 Below is the worker config:以下是工作人员配置:

name=sink-mongonew_Transaction_test4
connector.class=com.mongodb.kafka.connect.MongoSinkConnector
connection.uri=mongodb://****:27017
database=ec_ods
topics=t6,t5
collections=abc,def
collection.t6=abc
collection.t5=def
type.name=kafka-connect
key.ignore=true
document.id.strategy.abc=com.mongodb.kafka.connect.sink.processor.id.strategy.PartialValueStrategy
value.projection.type.abc=whitelist
value.projection.list.abc=ID
writemodel.strategy.abc=com.mongodb.kafka.connect.sink.writemodel.strategy.UpdateOneTimestampsStrategy
document.id.strategy.def=com.mongodb.kafka.connect.sink.processor.id.strategy.PartialValueStrategy
value.projection.type.def=whitelist
value.projection.list.def=ID
writemodel.strategy.def=com.mongodb.kafka.connect.sink.writemodel.strategy.UpdateOneTimestampsStrategy
delete.on.null.values=false
key.converter=org.apache.kafka.connect.json.JsonConverter
value.converter=org.apache.kafka.connect.json.JsonConverter
key.converter.schemas.enable=false
value.converter.schemas.enable=false
internal.key.converter=org.apache.kafka.connect.json.JsonConverter
internal.value.converter=org.apache.kafka.connect.json.JsonConverter
internal.key.converter.schemas.enable=false
internal.value.converter.schemas.enable=false

https://github.com/mongodb/mongo-kafka/blob/master/config/MongoSinkConnector.properties https://github.com/mongodb/mongo-kafka/blob/master/config/MongoSinkConnector.properties

I found a different way of using multiple collections in the above link, which uses overriding, and even allows the use of global as well as local attributes assignment for multiple collections at the same time.我在上面的链接中发现了一种使用多个集合的不同方式,它使用覆盖,甚至允许同时为多个集合使用全局和局部属性分配。

Here a link to a proper documentation of the MongoDB Kafka sink connector https://github.com/mongodb-labs/mongo-kafka/blob/master/docs/sink.md这里是 MongoDB Kafka sink 连接器的正确文档的链接https://github.com/mongodb-labs/mongo-kafka/blob/master/docs/sink.md

As per documentation, you should use the topic.override.%s.%s property根据文档,您应该使用 topic.override.%s.%s 属性

The overrides configuration allows for per topic customization of configuration.覆盖配置允许按主题自定义配置。 The customized overrides are merged with the default configuration, to create the specific configuration for a topic.自定义覆盖与默认配置合并,以创建主题的特定配置。 For example, topic.override.foo.collection=bar will store data from the foo topic into the bar collection.例如,topic.override.foo.collection=bar 会将来自 foo 主题的数据存储到 bar 集合中。 Note: All configuration options apart from 'connection.uri' and 'topics' are overridable.注意:除了“connection.uri”和“topics”之外的所有配置选项都是可覆盖的。 string ""细绳 ””

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM