Skip to main content
Version: 3.3.x

MongoDB sink connector


You can download all the Pulsar connectors on download page.

The MongoDB sink connector pulls messages from Pulsar topics and persists the messages to collections.


The configuration of the MongoDB sink connector has the following properties.


mongoUriStringtrue" " (empty string)The MongoDB URI to which the connector connects.

For more information, see connection string URI format.
databaseStringtrue" " (empty string)The database name to which the collection belongs.
collectionStringtrue" " (empty string)The collection name to which the connector writes messages.
batchSizeintfalse100The batch size of writing messages to collections.
batchTimeMslongfalse1000The batch operation interval in milliseconds.


Before using the Mongo sink connector, you need to create a configuration file through one of the following methods.

  • JSON

    "configs": {
    "mongoUri": "mongodb://localhost:27017",
    "database": "pulsar",
    "collection": "messages",
    "batchSize": "2",
    "batchTimeMs": "500"
  • YAML

    mongoUri: "mongodb://localhost:27017"
    database: "pulsar"
    collection: "messages"
    batchSize: 2
    batchTimeMs: 500