Docs Menu

Docs HomeMongoDB Kafka Connector

Kafka Topic Properties

On this page

  • Overview
  • Settings

Use the following configuration settings to specify which Kafka topics the source connector should publish data to.

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

Name
Description
topic.prefix
Type: string

Description:
The prefix to prepend to database and collection names to generate the name of the Kafka topic on which to publish the data.

Tip

See also:

Default: ""
Accepted Values: A string composed of ASCII alphanumeric characters including ".", "-", and "_"
topic.suffix
Type: string

Description:
The suffix to append to database and collection names to generate the name of the Kafka topic on which to publish the data.
Default: ""
Accepted Values: A string composed of ASCII alphanumeric characters including ".", "-", and "_"
topic.namespace.map
Type: string

Description:
Specifies a JSON mapping between change stream document namespaces and topic names.

Example

The following mapping instructs the connector to perform the following actions:

  • Publish change stream documents originating from the myDb.myColl MongoDB collection to the topicOne Kafka topic.

  • Publish change stream documents originating from the myDb MongoDB database and a collection other than myColl to the Kafka topic topicTwo.<collectionName>.

  • Publish change stream documents originating from the myDb MongoDB database that do not bear a collection name to the topicTwo Kafka topic.

topic.namespace.map={"myDb.myColl": "topicOne", "myDb": "topicTwo"}

The following examples show which topic the connector sends different change stream documents to using the preceding mapping:

  • A change stream document originating from the myDb database and the myColl collection publishes to the topicOne topic.

  • A change stream document originating from the myDb database and the newColl collection publishes to the topicTwo.newColl topic.

  • A change stream document originating from dropping the myDb database, which does not bear a collection name, publishes to the topicTwo topic.

You can use the "*" wildcard character to match change stream document namespaces.

Example

The following mapping instructs the connector to publish all change stream documents to the topicThree topic:

topic.namespace.map={"*": "topicThree"}
Default: ""
Accepted Values: A valid JSON object
topic.mapper
Type: string

Description:
The Java class that defines your custom topic mapping logic.

Default: com.mongodb.kafka.connect.source.topic.mapping.DefaultTopicMapper
←  MongoDB Source Connection PropertiesChange Stream Properties →

On this page