带有doneFileName的Apache骆驼文件 [英] Apache camel file with doneFileName

查看:131
本文介绍了带有doneFileName的Apache骆驼文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始查看apache骆驼(使用蓝图路线),但是我已经被卡住了.

I am just starting to look at apache camel (Using blueprint routes) and I am already stuck.

我需要处理一组具有不同格式的csv文件.我使用foo_X_20160110.csv获得了5个文件,其中X指定了csv文件的类型,并且文件具有日期戳.这些文件可能很大,因此一旦写入所有文件,便会写入完成"文件.完成的文件名为foo_trigger_20160110.csv.

I need to process a set of csv files with different formats. I get 5 files with foo_X_20160110.csv were X specifies the type of csv file and the files have a date stamp . These files can be quite large so a 'done' file is written once all files are written. The done file is named foo_trigger_20160110.csv.

我已经在文件上看到了doneFileName选项,但是它仅支持静态名称(文件名中有一个日期),或者每个输入文件都需要一个完成的文件.

I've seen the doneFileName option on file but that only supports a static name (I have a date in the filename) or it expects a done file for each input file.

文件必须以固定顺序进行,但是不能保证文件以什么顺序写入输入目录.因此,我需要等待完成的文件.

The files have to be proceeded in a fixed order but it is not guaranteed in which order they are written to the input directory. Hence I need to wait for the done file.

有什么想法可以用骆驼来做到吗?

Any idea how this can be done with Camel?

对好的骆驼书有何建议?

Any suggestions for good Camel books?

推荐答案

以下是文档中的示例 http://camel.apache.org/file2.html

Here is an example from the documentation http://camel.apache.org/file2.html

from("file:C:/temp/input.txt?doneFileName=done");

如您所见,doneFileName具有静态值"done".但是您可以使用标准的Java来编写动态名称,即针对当前的dateformat或其他任何格式,而只需使用字符串操作即可构造URI.希望有帮助.

As you can see the doneFileName has a static value "done". But you can use standard java to write dynamic names i.e. for current dateformat or anything else and just use string operation to construct the URI. Hope that helps.

更新:

顺便说一句,如文档中所述,doneFileName可以使用动态占位符.

By the way, as mentioned in the documentation there is the option of dynamic placeholders for the doneFileName.

但是,通常每个目标文件只有一个完成文件.这 表示存在1:1的相关性.为此,您必须使用动态 doneFileName选项中的占位符.目前骆驼支持 以下两个动态令牌:file:name和file:name.noext,必须 括在$ {}中.使用者仅支持 完成的文件名可以是前缀或后缀(不是两者都可以).

However its more common to have one done file per target file. This means there is a 1:1 correlation. To do this you must use dynamic placeholders in the doneFileName option. Currently Camel supports the following two dynamic tokens: file:name and file:name.noext which must be enclosed in ${ }. The consumer only supports the static part of the done file name as either prefix or suffix (not both).

from("file:bar?doneFileName=${file:name}.done");

您还可以为完成的文件使用前缀,例如:

You can also use a prefix for the done file, such as:

from("file:bar?doneFileName=ready-${file:name}");

这篇关于带有doneFileName的Apache骆驼文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆