Skip to main content
Version: Next

MongoDB sink connector

note

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.

Configuration

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

Property

NameTypeRequiredDefaultDescription
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.

Example

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

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