简体   繁体   English

从Node.js批量加载titan db中的数据

[英]Bulk load data in titan db from nodejs

My current scenario is like 我目前的情况是

  1. I have a rabbit mq which gives me the details of the order placed. 我有一个兔子mq,可以给我下订单的详细信息。
  2. On the other side I have my titan db (cassandra storage, es index backends and gremlin server). 另一方面,我有我的titan db(cassandra存储,es索引后端和gremlin服务器)。
  3. Yet another I have nodejs application which can interact with gremlin server through http api using https://www.npmjs.com/package/gremlin . 我还有另一个nodejs应用程序,可以使用https://www.npmjs.com/package/gremlin通过http api与gremlin服务器进行交互。 I am able to make hits to my graph database from here. 我可以从这里点击我的图形数据库。

Now what I am trying to do is load data from rabbit mq into titan db. 现在,我想做的是将Rabbit MQ中的数据加载到titan db中。

What I have been able to do till now is load the data from nodejs file using gremlin node module 到目前为止,我只能使用gremlin节点模块从nodejs文件加载数据

  var createClient = require('gremlin').createClient; //import { createClient } from 'gremlin'; const client = createClient(); client.execute('tx=graph.newTransaction();tx.addVertex(T.label,"product","id",991);tx.commit()', {}, function(err, results){ if (err) { return console.error(err) } console.log(results) }); 

How should I move next so that I can harness existing rabbit mq of orders and push them into titan db. 接下来我应该如何移动,以便可以利用现有的兔子mq订单并将其推入titan db。

Due to some constraints I can not use java. 由于某些限制,我无法使用Java。

You're most likely looking for something like node-amqp , which is a Node.js client for RabbitMQ. 您很可能正在寻找类似node-amqp的东西,这是RabbitMQ的Node.js客户端。 What you want to do is: 您想要做的是:

  1. Establish a connection to Gremlin Server 建立与Gremlin Server的连接
  2. Establish a connection to RabbitMQ 建立与RabbitMQ的连接
  3. Listen to a RabbitMQ queue for messages 收听RabbitMQ队列中的消息
  4. Send these messages to Gremlin, creating graph elements 将这些消息发送到Gremlin,创建图形元素

Things you must watch for that will otherwise likely kill your performance: 您必须注意的事情否则可能会损害您的性能:

  1. Send Gremlin queries with bound parameters 使用绑定的参数发送Gremlin查询
  2. Batch messages: create multiple vertices and commit them in the same transaction (= same Gremlin query, unless in session mode where you .commit() yourself). 批处理消息:创建多个顶点并在同一事务中提交它们(=相同的Gremlin查询,除非在您自己.commit()会话模式下)。 Numbers in the couple thousands should work. 成千上万的数字应该起作用。
  3. Watchout for back-pressure and make sure you don't flood your Titan instances with more messages than they can handle. 当心背压,并确保您不会在Titan实例中充斥过多无法处理的消息。

I'm not familiar with RabbitMQ but hopefully this should get you started. 我对RabbitMQ不熟悉,但希望这可以帮助您入门。

Note: Gremlin javascript driver interacts with Gremlin Server via a WebSocket connection, which is permanent and bi-directional. 注意:Gremlin javascript驱动程序通过WebSocket连接与Gremlin Server交互,该连接是永久的和双向的。 The client doesn't support the HTTP Channelizer yet (which is not the kind of connection that you wish to establish in the current scenario). 客户端尚不支持HTTP Channelizer(这不是您希望在当前方案中建立的连接)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM