Mirth connect to mongo db connectivity

血红的双手。 提交于 2020-02-02 14:31:56

问题


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.


回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/29271713/mirth-connect-to-mongo-db-connectivity

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!