sink
MongoDB Sink
The MongoDB sink connector pulls messages from Pulsar topics and persists the messages to collections.
Authored by
ASF
Support type
StreamNative
License
Apache License 2.0

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

NameTypeRequiredSensitiveDefaultDescription
mongoUriStringtruetrue" " (empty string)The MongoDB URI to which the connector connects. <br><br>For more information, see connection string URI format.
databaseStringtruefalse" " (empty string)The database name to which the collection belongs.
collectionStringtruefalse" " (empty string)The collection name to which the connector writes messages.
batchSizeintfalsefalse100The batch size of writing messages to collections.
batchTimeMslongfalsefalse1000The 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

    {
        "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
    }