Docs Home → MongoDB Kafka Connector
Topic Naming
The example on this page shows how to configure your MongoDB Kafka source connector to customize the name of the topic to which it publishes records.
By default, the MongoDB Kafka source connector publishes change event data to a Kafka topic with the same name as the MongoDB namespace from which the change events originated. A namespace is a string that's composed of the database and collection name concatenated with a dot "." character.
Topic Prefix Example
You can configure your source connector to prepend a string to the namespace of the change event data, and publish records to that Kafka topic. This setting automatically concatenates your prefix with your namespace with the "." character.
To specify the topic prefix, use the topic.prefix
configuration
setting as shown in the following example:
topic.prefix=myPrefix database=test collection=data
Once set, your connector publishes any changes to the data
collection
in the test
database to the Kafka topic named myPrefix.test.data
.