在Apache的骆驼处理大型CSV文件的最佳策略 [英] Best strategy for processing large CSV files in Apache Camel
问题描述
我想开发民调包含CSV文件的目录,并为每个文件解组使用Bindy和队列它的ActiveMQ各行的路线。
I'd like to develop a route that polls a directory containing CSV files, and for every file it unmarshals each row using Bindy and queues it in activemq.
问题是,文件可以是pretty大(一百万行),所以我倒是preFER同时排队一排,但是我得到的是个java.util中的所有行.ArrayList在Bindy年底这会导致内存问题。
The problem is files can be pretty large (a million rows) so I'd prefer to queue one row at a time, but what I'm getting is all the rows in a java.util.ArrayList at the end of Bindy which causes memory problems.
到目前为止,我有一个小的测试和解组使用注释是好的工作,所以Bindy配置。
So far I have a little test and unmarshaling is working so Bindy configuration using annotations is ok.
下面是路线:
from("file://data/inbox?noop=true&maxMessagesPerPoll=1&delay=5000")
.unmarshal()
.bindy(BindyType.Csv, "com.ess.myapp.core")
.to("jms:rawTraffic");
环境:Eclipse的靛蓝,Maven的3.0.3,2.8.0骆驼
Environment is: Eclipse Indigo, Maven 3.0.3, Camel 2.8.0
感谢您
推荐答案
如果您使用分离器EIP那么你可以使用流模式,这意味着骆驼将根据行的基础上处理一排文件。
If you use the Splitter EIP then you can use streaming mode which means Camel will process the file on a row by row basis.
from("file://data/inbox?noop=true&maxMessagesPerPoll=1&delay=5000")
.split(body().tokenize("\n")).streaming()
.unmarshal().bindy(BindyType.Csv, "com.ess.myapp.core")
.to("jms:rawTraffic");
这篇关于在Apache的骆驼处理大型CSV文件的最佳策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!