简体   繁体   English

以小块溢出数据列表并使用执行器服务 java 对其进行处理

[英]Spilt list of data in small chunks and process it using Executor service java

My Requirement: I have 100k data, i need to split it into 1k dataset each and then process it(call REST API).我的要求:我有 100k 数据,我需要将其分成 1k 数据集,然后对其进行处理(调用 REST API)。

  1. What flow should I be using here?我应该在这里使用什么流程? Spilt 10k data into 1k and then call executor service?将 10k 数据溢出到 1k 中,然后调用执行器服务? I believe his approach might simply increase memory(while re-storing split data) or Split data and call REST API simultaneously?我相信他的方法可能只是增加内存(同时重新存储拆分数据)或拆分数据并同时调用 REST API?

  2. Should I use some Queue implementation?我应该使用一些队列实现吗?

  3. Is using Executor service the right approach?使用 Executor 服务是正确的方法吗?

  4. Is there any other extremely clean way of splitting huge data and call REST API?有没有其他非常干净的方法来拆分大量数据并调用 REST API?

Please Note: I am just looking for a nice "APPROACH/FLOW/DESIGN".请注意:我只是在寻找一个不错的“方法/流程/设计”。

Can someone suggest some approach?有人可以提出一些方法吗?

EDIT: I am fetching 100k Phone numbers from MongoDB.编辑:我从 MongoDB 获取 100k 电话号码。 I need to split it into batch of 1k each and send message.我需要将它分成每批 1k 并发送消息。 If any error occurs it can be logged in logger files(no need to handle this).如果发生任何错误,可以将其记录在记录器文件中(无需处理)。

This answer is targeted at your point 4:此答案针对您的第 4 点:

I would suggest that you have a look at Apache Camel or Apache NiFi to process this structure and amount of data.我建议您查看Apache CamelApache NiFi来处理这种结构和数据量。 If you don't know any of them yet, both systems will require that you get used to some new concepts.如果您还不了解它们中的任何一个,那么这两个系统都需要您习惯一些新概念。 NiFi is the more modern one, while Camel can be configured via Java. NiFi 是更现代的一种,而 Camel 可以通过 Java 进行配置。

Both systems should make it quite easy to read data from Mongo, split them and send out the REST requests.两个系统都应该可以很容易地从 Mongo 读取数据,拆分它们并发送 REST 请求。

On the other hand this might be too much overhead, if this is a one-time-only job to get done.另一方面,如果这是一次性完成的工作,这可能会产生过多的开销。 But it is useful if you need this job to run reliably over and over again.但是,如果您需要此作业一遍又一遍地可靠运行,它会很有用。

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

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