MongoDB 命名空间映射配置属性
Overview
使用以下配置设置指定 MongoDB Kafka connector 将数据写入哪个 MongoDB database 和 collection。您可以使用默认的 DefaultNamespaceMapper
或指定自定义类。
有关按类别整理的接收器Connector配置设置列表,请参阅有关接收器连接器配置属性的指南。
设置
名称 | 说明 | |
---|---|---|
namespace.mapper | Type: string Description: The fully-qualified class name of the class that specifies which
database or collection in which to sink the data. The default
DefaultNamespaceMapper uses values specified in the
database and collection properties.The connector includes an alternative class for specifying the database and collection called FieldPathNamespaceMapper . Seefor more information. Default:
Accepted Values: A fully qualified Java class name of a class that implements the NamespaceMapper interface. | |
database | Required Type: string Description: The name of the MongoDB database to which the sink connector writes. Accepted Values: A MongoDB database name | |
集合 | Type: string Description: The name of the MongoDB collection to which the sink connector
writes. If your sink connector follows multiple topics, this
is the default collection for any writes that are not otherwise
specified. Default: The topic name. Accepted Values: A MongoDB collection name |
FieldPathNamespaceMapper 设置
如果将接收器连接器配置为使用FieldPathNamespaceMapper
,则可以根据数据的字段值指定用于接收文档的数据库和集合。
要启用此映射行为,请将接收器connectornamespace.mapper
配置属性设置为完全限定的类名称,如下所示:
namespace.mapper=com.mongodb.kafka.connect.sink.namespace.mapping.FieldPathNamespaceMapper
FieldPathNamespaceMapper
要求您指定以下设置:
将属性映射到数据库和集合的一个或两个
到数据库的
key
或value
映射之一到collection的
key
或value
映射之一
您可以使用以下设置自定义FieldPathNamespaceMapper
的行为:
名称 | 说明 |
---|---|
namespace.mapper.key.database.field | Type: string Description: The name of the key document field that specifies the name of the
database in which to write. |
namespace.mapper.key.collection.field | Type: string Description: The name of the key document field that specifies the name of the
collection in which to write. |
namespace.mapper.value.database.field | Type: string Description: The name of the value document field that specifies the name of the
database in which to write. |
namespace.mapper.value.collection.field | Type: string Description: The name of the value document field that specifies the name of the
collection in which to write. |
namespace.mapper.error.if.invalid | Type: boolean Description: Whether to throw an exception when either the document is missing the
mapped field or it has an invalid BSON type. When set to true , the connector does not process documents
missing the mapped field or that contain an invalid BSON type.
The connector may halt or skip processing depending on the related
error-handling configuration settings.When set to false , if a document is missing the mapped field or
if it has an invalid BSON type, the connector defaults to
writing to the specified database and collection settings.Default: false Accepted Values: true or false |