Connect to MongoDB¶
Learn how to connect the MongoDB Kafka Connector to MongoDB using a connection Uniform Resource Identifier (URI). A connection URI is a string that contains the following information:
- The address of your MongoDB deployment required
- Connection settings optional
- Authentication settings optional
- Authentication credentials optional
The following is an example of a connection URI for a MongoDB replica set:
To learn more about the connection URI format, see Connection String URI Format in the MongoDB Manual.
How to Connect¶
Specify a connection URI with the following configuration option in both a source and sink connector:
connection.uri=<your connection uri>
To learn more about this configuration option, see the following resources:
How to Configure Your Connection¶
The MongoDB Kafka Connector uses the MongoDB Java driver to parse your connection URI. The MongoDB Java driver is an artifact that enables Java applications like Kafka Connect to interact with MongoDB.
Version 1.6 of the MongoDB Kafka Connector uses version 4.3 of the MongoDB Java driver.
To learn what connection URI options are available in the MongoDB Kafka Connector, see the MongoDB Java driver Connection guide.
All authentication mechanisms available in the MongoDB Java driver are available in the MongoDB Kafka Connector.
The following is an example of a connection URI that authenticates with MongoDB using
To avoid storing your authentication secrets as plain text in your
setting, load your secrets from a secure location as your connector starts.
To learn how to load your secrets as your connector starts, see
the Externalize Secrets guide from Confluent.
To learn what authentication mechanisms are available, see the MongoDB Java driver Authentication Mechanisms guide.
To learn more about authentication in the MongoDB Kafka Connector, see the Security and Authentication guide.