Overview
次の構成設定を使用して、MongoDB Kafka Sink Connector がデータを書き込む MongoDB database とコレクションを指定します。 デフォルトの DefaultNamespaceMapperを使用することも、カスタム クラスを指定することもできます。
カテゴリ別に整理された Sink Connector 構成設定のリストについては、 Sink 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
 DefaultNamespaceMapperuses values specified in thedatabaseandcollectionproperties.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  NamespaceMapperinterface. | |
| 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を使用するように Sink Connector を構成すると、データの フィールド値に基づいて、ドキュメントを Sink するデータベースとコレクションを指定できます。
このマッピング動作を有効にするには、以下に示すように、Sink Connector namespace.mapper構成プロパティを完全修飾クラス名に設定します。
namespace.mapper=com.mongodb.kafka.connect.sink.namespace.mapping.FieldPathNamespaceMapper 
FieldPathNamespaceMapperでは、次の設定を指定する必要があります。
- プロパティをデータベースとコレクションにマッピングする 1 つまたは両方 
- データベースへの - keyまたは- valueマッピングの 1 つ
- コレクションへの マッピングまたは マッピングの 1 つ - 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 specifieddatabaseandcollectionsettings.Default:  falseAccepted Values:  trueorfalse |