2
votes

I want to connect mongodb using mirth connect. can any one provide me a sample channel for the same. also any one have any statistics that in a minute how many message we can process using mirth connect.

2

2 Answers

4
votes

This an example I created myself to test MongoDB with Mirth.

On the source connector, choose the type as Javascript and copy the following code, based on the example available at the MongoDB Java Driver webpage here:

var mongoClient = new Packages.com.mongodb.MongoClient("localhost", 27017);
var database = mongoClient.getDatabase("mydb");
var collection = database.getCollection("test");
/*
var doc = new Packages.org.bson.Document("name", "MongoDB")
                       .append("type", "database")
                       .append("count", 1)
                       .append("info", new Packages.org.bson.Document("x", 203).append("y", 102));
*/                     
var jsonDoc = JSON.stringify({ "name" : "MongoDB", "type" : "database", "count" : 1.0, "info" : { "x" : 203.0, "y" : 102.0 } });

var doc = Packages.org.bson.Document.parse(jsonDoc);

// drop all the data in it
collection.drop();

collection.insertOne(doc);

// get it (since it's the only one in there since we dropped the rest earlier on)
var myDoc = collection.find().first();

logger.debug(myDoc.toJson());

mongoClient.close();

return;

The commented code creates a BSON document using Java, while the other parses a JSON to BSON, as it would normally happen in Mirth if receiving, for instance, a FHIR resource in JSON.

One important thing to do: you have to copy the following jars to custom-lib from their repository here

  • bson
  • mongodb-driver
  • mongodb-driver-core
0
votes

Check this thread over at the Mirth Community Forums.

There are posts by Nick Rupley (who is the defacto expert on all things Mirth), as well as some posts by people who've successfully implemented the connection.

As to your question regarding performance. It all depends on the host server.

We are running a PICO-1000 Virtual Appliance on a massive VMWare Server with huge resources and can process 1000's of messages a second through 120 channels without a hitch.

Things to watch for are if you chose to handle responses in the response transformer that you implement elegant exception/error handling as a problem at that stage will prevent that channel from processing anything.