MongoDB Source Connector
Type |
source |
Class |
|
Target System |
MongoDB |
Maintainer |
MongoDB |
License |
Apache License 2.0 |
Project |
|
Download |
|
This page documents version 2.1.0. 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 MongoDB Source Connector streams data from MongoDB collections into Kafka topics using MongoDB Change Streams.
It is maintained by MongoDB as part of the open-source github.com/mongodb/mongo-kafka.
The connector watches MongoDB change streams, a native MongoDB feature that provides an ordered, resumable stream of change events. Unlike the Debezium MongoDB CDC Connector, this connector is maintained directly by MongoDB and uses the official MongoDB Kafka driver.
Features
-
Stream change events from MongoDB collections using MongoDB Change Streams
-
Captures inserts, updates, replaces, and deletes
-
Configurable pipeline for filtering change stream events
-
Supports full document lookup on updates
-
Resumable — stores resume tokens to survive connector restarts
When to Use
-
You need to stream MongoDB change events into Kafka.
-
You want the officially maintained MongoDB connector rather than the Debezium variant.
-
You need full document content on update events (
fullDocument: updateLookup).
When NOT to Use
-
You need CDC from a MongoDB replica set without change streams enabled — use the Debezium MongoDB CDC Connector instead.
-
You only need a one-time bulk export of MongoDB data.
Installation
The connector is available from the MongoDB Kafka Connector installation.
-
Follow the MongoDB documentation to download and install the connector JAR.
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. |
Getting Started
Prerequisites
MongoDB instance
You need a running MongoDB replica set or Atlas cluster reachable from the Kafka Connect cluster. MongoDB Change Streams require a replica set — standalone MongoDB instances are not supported.
Axual stream
The stream where the connector will produce events must already exist in Axual Self-Service. See Creating streams if you need to create it.
Steps
Step 1 — Create a connector application
-
Follow the Configure and install a connector documentation to set up a new Connector-Application.
Let’s call itmy_mongodb_source_app.
The plugin name iscom.mongodb.kafka.connect.MongoSourceConnector.
If a plugin isn’t available, ask a platform operator to install plugins.
Step 2 — Configure the connector
-
Provide the following minimal configuration:
connection.urimongodb://username:password@mongodb.example.com:27017/?replicaSet=rs0databaseYour MongoDB database name
collectionYour MongoDB collection name
topic.prefixmongodb_orderskey.converterorg.apache.kafka.connect.storage.StringConvertervalue.converterorg.apache.kafka.connect.json.JsonConvertervalue.converter.schemas.enablefalseFor advanced options, see the official source connector documentation.
-
Authorize the
my_mongodb_source_appsource Connector-Application to produce to themongodb_ordersstream.
Known limitations
-
MongoDB Change Streams require a replica set — standalone MongoDB deployments are not supported.
-
Resume tokens are stored in Kafka Connect’s offset storage. If offsets are lost, the connector restarts from the beginning or a configurable start timestamp.
Examples
Minimal configuration
{
"name": "my-mongodb-source",
"config": {
"connector.class": "com.mongodb.kafka.connect.MongoSourceConnector",
"connection.uri": "mongodb://username:password@mongodb.example.com:27017/?replicaSet=rs0",
"database": "my_database",
"collection": "orders",
"topic.prefix": "mongodb_orders",
"key.converter": "org.apache.kafka.connect.storage.StringConverter",
"value.converter": "org.apache.kafka.connect.json.JsonConverter",
"value.converter.schemas.enable": "false"
}
}
License
MongoDB source connector is licensed under the Apache License, Version 2.0.