简体   繁体   English

如何使用apachecamel仅删除ftp服务器上已处理的文件

[英]How to delete only processed files on ftp server with apache camel

I have the following route declared in camel:我在骆驼中声明了以下路线:

from(eodRepository + "?delete=true")
    .filter(header("CamelFileName").regex(myPattern))
    .log(DEBUG, "Decrypting file ${header.CamelFileName}")
    .unmarshal(pgpDataFormat)
    .log(DEBUG, "Processing file ${header.CamelFileName}")
    .unmarshal(myBusinessDataFormat)
    .bean(myBean, "processIt")
    .log(INFO, "Processed file ${header.CamelFileName}");

The above consumes files matching the filter from eodRepository (an sftp folder) however delete=true on the endpoint is deleting all files in the sftp folder instead of just the ones that have been processed.以上使用与来自 eodRepository(一个 sftp 文件夹)的过滤器匹配的文件,但是端点上的 delete=true 是删除 sftp 文件夹中的所有文件,而不仅仅是已处理的文件。

Does anyone know how I can make sure only the processed files get deleted and the remainder is left on the endpoint?有谁知道我如何确保只有处理过的文件被删除,其余的留在端点上?

You need to specify the file name filtering in the endpoint uri, and NOT the filter EIP in the route.您需要在端点 uri 中指定文件名过滤,而不是路由中的过滤器 EIP。

You can use the include option which is using reg exp:您可以使用使用 reg exp 的 include 选项:

"?delete=true&include=" + pattern

The ftp docs: https://github.com/apache/camel/blob/master/components/camel-ftp/src/main/docs/ftp-component.adoc ftp 文档: https : //github.com/apache/camel/blob/master/components/camel-ftp/src/main/docs/ftp-component.adoc

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

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