Docs Menu

Docs HomeDevelop ApplicationsMongoDB Kafka Connector

Sink Connector Write Model Strategies

On this page

  • Overview
  • Write Model
  • Delete Write Model
  • Strategies

You can set configuration properties to specify how the MongoDB Kafka sink connector writes data into MongoDB. The following sections describe the configuration properties that you can set to customize this behavior.

Set the writemodel.strategy configuration property to specify how the sink connector writes data when it receives a sink record.

You can set the value of writemodel.strategy to any of the fully qualified class names of the write model strategies described in the Strategies section of this page. You can specify a strategy by setting the following configuration:

writemodel.strategy=<a write model strategy>

Set the delete.writemodel.strategy configuration property to specify how the sink connector writes data when it receives a tombstone event. A tombstone event is a record that contains a key but no value, which signifies a deleted record.

You can set the value of delete.writemodel.strategy to any of the fully qualified class names of the write model strategies described in the Strategies section of this page. You can specify a strategy by setting the following configuration:

delete.writemodel.strategy=<a write model strategy>

For a list of sink connector configuration settings organized by category, see the guide on Sink Connector Configuration Properties.

Name
Description
DefaultWriteModelStrategy

Description:
This strategy uses the ReplaceOneDefaultStrategy by default, and the InsertOneDefaultStrategy if you set the timeseries.timefield option.

This is the default value value for the writemodel.strategy configuration property.
InsertOneDefaultStrategy

Description:
Insert each sink record into MongoDB as a document.
To specify this strategy, set the configuration property to the following class name:
com.mongodb.kafka.connect.sink.writemodel.strategy.InsertOneDefaultStrategy
ReplaceOneDefaultStrategy

Description:
Replaces at most one document in MongoDB that matches a sink record by the _id field. If no documents match, the connector inserts the sink record as a new document.
To specify this strategy, set the configuration property to the following class name:
com.mongodb.kafka.connect.sink.writemodel.strategy.ReplaceOneDefaultStrategy
ReplaceOneBusinessKeyStrategy

Description:
Replaces at most one document that matches a sink record by a specified business key. If no documents match, the connector inserts the sink record as a new document.
To specify this strategy, set the configuration property to the following class name:
com.mongodb.kafka.connect.sink.writemodel.strategy.ReplaceOneBusinessKeyStrategy
To see an example showing how to use this strategy, see our guide on write model strategies.
DeleteOneDefaultStrategy

Description:
Deletes at most one document that matches your sink connector's key structure by the _id field only when the document contains a null value structure.

This is the default value for the delete.writemodel.strategy configuration property.

This strategy is set as the default value of the writemodel.strategy property when you set mongodb.delete.on.null.values=true.
To specify this strategy, set the configuration property to the following class name:
com.mongodb.kafka.connect.sink.writemodel.strategy.DeleteOneDefaultStrategy
DeleteOneBusinessKeyStrategy

Description:
Deletes at most one MongoDB document that matches a sink record by a business key.
To specify this strategy, set the configuration property to the following class name:
com.mongodb.kafka.connect.sink.writemodel.strategy.DeleteOneBusinessKeyStrategy
To see an example showing how to use this strategy, see our guide on write model strategies.
UpdateOneDefaultStrategy

Description:
Updates at most one document in MongoDB that matches a sink record by the _id field. If no documents match, the connector inserts the sink record as a new document.
To specify this strategy, set the configuration property to the following class name:
com.mongodb.kafka.connect.sink.writemodel.strategy.UpdateOneDefaultStrategy
UpdateOneTimestampsStrategy

Description:
Add _insertedTS (inserted timestamp) and _modifiedTS (modified timestamp) fields into documents.
To specify this strategy, set the configuration property to the following class name:
com.mongodb.kafka.connect.sink.writemodel.strategy.UpdateOneTimestampsStrategy
To see an example showing how to use this strategy, see our guide on write model strategies.
UpdateOneBusinessKeyTimestampStrategy

Description:
Add _insertedTS (inserted timestamp) and _modifiedTS (modified timestamp) fields into documents that match a business key.
To specify this strategy, set the configuration property to the following class name:
com.mongodb.kafka.connect.sink.writemodel.strategy.UpdateOneBusinessKeyTimestampStrategy
←  Sink Connector Id Strategy PropertiesTopic Override Properties →