Striim 3.9.4 / 3.9.5 documentation

MongoDBReader example application and output

The following Striim application will write change data for the specified collection to SysOut. To run this yourself, replace striim and ****** with the user name and password for the MongoDB user account discussed in MongoDB setup, specify the correct connection URL for your instance, and replace mydb with the name of your database.

CREATE APPLICATION MongoDBTest;

CREATE SOURCE MongoDBIn USING MongoDBReader (
  Username:'striim',
  Password:'******',
  ConnectionURL:'192.168.1.10:27107',
  Collections:'mydb.employee'
) 
OUTPUT TO MongoDBStream;

CREATE TARGET MongoDBCOut
USING SysOut(name:MongoDB)
INPUT FROM MongoDBStream;

END APPLICATION MongoDBTest;

With the above application running, the following MongoDB shell commands:

use mydb;
db.employee.save({_id:1,"firstname":"Larry","lastname":"Talbot","age":10,"comment":"new record"});
db.employee.save({_id:1,"firstname":"Larry","lastname":"Talbot","age":40,"comment":"updated record"});
db.employee.update({_id:1},{$set:{"comment":"partial update"}});
db.employee.remove({_id:1});

would produce output similar to the following:

data: {"_id":1.0,"firstname":"Larry","lastname":"Talbot","age":10.0,"comment":"new record"}
metadata: {"CollectionName":"employee","OperationName":"INSERT","DatabaseName":"mydb",
  "DocumentKey":1.0,"NameSpace":"mydb.employee","TimeStamp":1537250474}
...
data: {"_id":1.0,"firstname":"Larry","lastname":"Talbot","age":40.0,"comment":"updated record"}
metadata: {"CollectionName":"employee","OperationName":"UPDATE","DatabaseName":"mydb",
  "DocumentKey":1.0,"NameSpace":"mydb.employee","TimeStamp":1537250474}
...
data: {"_id":1.0,"comment":"partial update"}
metadata: {"CollectionName":"employee","OperationName":"UPDATE","DatabaseName":"mydb",
  "DocumentKey":1.0,"NameSpace":"mydb.employee","TimeStamp":1537250474}
...
data: {"_id":1.0}
metadata: {"CollectionName":"employee","OperationName":"DELETE","DatabaseName":"mydb",
  "DocumentKey":1.0,"NameSpace":"mydb.employee","TimeStamp":1537250477}

The Mongo Java driver adds the decimals. These have no effect.

Note that output for the "partial" update and delete operations includes only the fields specified in the shell commands. See Replicating MongoDB data to Azure CosmosDB for discussion of the issues this can cause when writing to targets and how to work around those issues.