Mirth连接到Mongo DB连接

编程入门 行业动态 更新时间:2024-10-27 02:28:11
本文介绍了Mirth连接到Mongo DB连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使用mirth connect连接mongodb.任何人都可以为我提供一个示例频道吗? 而且任何人都有任何统计数据,在一分钟内我们可以使用mirth connect处理多少条消息.

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.

推荐答案

我创建了一个示例,用于用Mirth测试MongoDB.

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

在源连接器上,根据MongoDB Java驱动程序网页此处:

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.mongodb.MongoClient("localhost", 27017); var database = mongoClient.getDatabase("mydb"); var collection = database.getCollection("test"); /* var doc = new Packages.bson.Document("name", "MongoDB") .append("type", "database") .append("count", 1) .append("info", new Packages.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.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;

注释后的代码使用Java创建了一个BSON文档,而另一个代码则将JSON解析为BSON,这通常发生在Mirth中,例如,如果接收到JSON中的FHIR资源.

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.

一件重要的事情:您必须将以下jar从其存储库复制到custom-lib 此处

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

  • bson
  • mongodb驱动程序
  • mongodb-driver-core

更多推荐

Mirth连接到Mongo DB连接

本文发布于:2023-11-22 21:06:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619023.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   Mirth   DB   Mongo

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!