CDC — MongoDB Source Connector
Type |
source |
Class |
|
Target System |
MongoDB |
Maintainer |
Debezium / Red Hat |
License |
Apache License 2.0 |
Project |
|
Download |
|
This page documents version 3.0.8.Final. Newer versions should be compatible unless there are breaking changes, but field names or default values may differ. If you notice discrepancies, please contact Axual Support. |
Description
The Debezium MongoDB CDC Source Connector captures change events from MongoDB replica sets or sharded clusters using the MongoDB Change Streams API and publishes them as records to Kafka topics.
It is maintained by the Debezium community as part of the open-source github.com/debezium/debezium.
The connector uses MongoDB Change Streams to tail document-level changes in real time. Change Streams require a replica set or sharded cluster — standalone MongoDB instances are not supported.
Features
-
Real-time Change Data Capture (CDC) from MongoDB collections
-
Captures inserts, updates, and deletes
-
Stream name follows the convention
<topic.prefix>.<db_name>.<collection_name> -
Works with MongoDB Atlas cloud clusters
When to Use
-
You need real-time CDC from MongoDB collections into Kafka.
-
You want to capture all DML events (inserts, updates, deletes) from MongoDB.
When NOT to Use
-
You only need periodic polling — consider a JDBC-style connector instead.
-
You do not have a MongoDB replica set or sharded cluster (standalone MongoDB is not supported).
Installation
The connector is available from the Debezium Releases.
-
Navigate to the releases page and select the version matching your Kafka Connect installation.
-
Download the JAR file.
For installation steps, see Installing Connector Plugins.
Configuration
For the complete configuration reference, see the official source connector documentation.
| To configure a connector in Axual Self-Service, see Starting Connectors. |
| For Infrastructure-as-Code deployment, see the Axual Kafka Connect Boilerplates group which contains Terraform and Management API boilerplates for other connectors. |
Axual Platform requirements
When running this connector on the Axual Platform, supply the following additional properties to disable automatic topic creation.
The connector has a bug that requires the topic.creation.default.* workaround properties even when topic.creation.enable is set to false.
|
|
|
|
|
|
Getting Started
Prerequisites
MongoDB instance
-
Deploy a free shared MongoDB cloud cluster.
During the "security quickstart" step:-
Create credentials. Remember these credentials.
-
Authorize IP addresses to access the cluster. Simplest: authorize
0.0.0.0/0.
-
-
Go to "Database", find your cluster, click
…→ Load Sample dataset, and wait for import to complete. -
Go to Database → click Connect on your cluster → choose Connect your application.
Copy the connection string (e.g.mongodb+srv://<user>:<password>@ab-cdef1gh.i2j3klm.mongodb.net).
This is themongodb.connection.stringvalue.
Axual streams
The stream name follows the convention: <topic.prefix>.<db_name>.<collection_name>.
Create one stream per collection you intend to watch. For this example, create:
-
mongo_nickname.sample_mflix.comments
All streams should use Key/Value type String/String.
See Creating streams if you need to create streams.
Steps
Step 1 — Create a connector application
-
Follow the Creating streams documentation in order to create one stream and deploy it onto an environment.
The name of the stream will bemongo_nickname.sample_mflix.comments.
The key/value types will beString/String.The stream name follows the convention:
<topic.prefix>.<db_name>.<collection_name>. One stream is needed for every collection being watched. -
Follow the Configure and install a connector documentation to set up a new Connector-Application.
Let’s call itmy_comments_app.
The plugin name isio.debezium.connector.mongodb.MongoDbConnector.
If a plugin isn’t available, ask a platform operator to install plugins.
Step 2 — Configure the connector
-
Provide the following minimal configuration:
mongodb.connection.stringExample value:
mongodb+srv://mongo_user:MongoSecret99@ac-abcd1ef.abcdefg.mongodb.nettopic.prefixmongo_nicknamedatabase.include.listsample_mflixcollection.include.listsample_mflix.commentsAlso supply the Axual Platform-required properties described in [_axual_platform_requirements].
-
Authorize the
my_comments_appsource Connector-Application to produce to themongo_nickname.sample_mflix.commentsstream.
Step 4 — Verify
In Axual Self-Service, use stream-browse on the mongo_nickname.sample_mflix.comments stream to confirm CDC events are arriving.
Cleanup
When you are done:
-
Stop the connector application in Axual Self-Service.
-
Remove stream access for the application if no longer needed.
-
If deployed via MongoDB Cloud, terminate your cluster:
-
Click the cluster → Click the
…three dots → Click Terminate -
Follow MongoDB’s instructions to finalize the termination process.
-
Known limitations
-
Standalone MongoDB instances are not supported — a replica set or sharded cluster is required.
-
topic.creation.enable=falsemust be set explicitly; the connector has a bug that requires the additionaltopic.creation.default.*properties as a workaround. See [_axual_platform_requirements]. -
The deprecated
mongodb.hosts,mongodb.name,mongodb.user, andmongodb.passwordproperties are replaced bymongodb.connection.stringandtopic.prefixin Debezium 2.x.
Examples
Minimal configuration
{
"name": "my-debezium-mongodb-source",
"config": {
"connector.class": "io.debezium.connector.mongodb.MongoDbConnector",
"tasks.max": "1",
"mongodb.connection.string": "mongodb+srv://mongo_user:MongoSecret99@ac-abcd1ef.abcdefg.mongodb.net",
"topic.prefix": "mongo_nickname",
"database.include.list": "sample_mflix",
"collection.include.list": "sample_mflix.comments",
"topic.creation.enable": "false",
"topic.creation.default.partitions": "1",
"topic.creation.default.replication.factor": "3"
}
}
License
Debezium source connector is licensed under the Apache License, Version 2.0.