Apache camel apachecamel:如何使用Premove、Move和MoveFailed选项从SFTP下载多个文件?
我有两个文件名,格式如下:Apache camel apachecamel:如何使用Premove、Move和MoveFailed选项从SFTP下载多个文件?,apache-camel,integration,spring-camel,camel-ftp,camel-http,Apache Camel,Integration,Spring Camel,Camel Ftp,Camel Http,我有两个文件名,格式如下: Gontagrator_1.xml Gontagrator_2.xml 到目前为止,我只选择Gontagrater_1.xml并将其重命名为processing,一旦完成,就失败了 + "&fileName=" + sftpFileName + "&preMove="+sftpFileName+".$simple{date:now:yyyy-MM-dd'T'hh-mm-ss}.processing"
Gontagrator_1.xml
Gontagrator_2.xml
到目前为止,我只选择Gontagrater_1.xml并将其重命名为processing,一旦完成,就失败了
+ "&fileName=" + sftpFileName
+ "&preMove="+sftpFileName+".$simple{date:now:yyyy-MM-dd'T'hh-mm-ss}.processing"
+ "&move="+sftpFileName+".$simple{date:now:yyyy-MM-dd'T'hh-mm-ss}"
+ "&moveFailed="+sftpFileName+".$simple{date:now:yyyy-MM-dd'T'hh-mm-ss}.failed"
现在,Gontagrator_2出现在图片中。建议为两者创建单独的路线
我们是否可以在一个路由中下载这两个文件并相应地重命名?如果是,我需要传递哪些值
更新1:有多个不同名称的文件,但我只需要使用以上两个文件名
更新2:组件的整体为:
"{{m.protocol}}://{{m.hostname}}{{t.directory}}"
+ "?username={{m.username}}"
+ "&password={{m.password}}"
+ "&download=true"
+ "&useList=false"
+ "&stepwise=false"
+ "&disconnect=true"
+ "&passiveMode=true"
+ "&reconnectDelay=10000"
+ "&bridgeErrorHandler=true"
+ "&delay=30000"
//+ "&fileName=" + sftpFileName
+ "&include="+ sftpFileName
+ "&preMove=$simple{file:onlyname}.$simple{date:now:yyyy-MM-dd'T'hh-mm-ss}.processing"
+ "&move=$simple{file:onlyname}.$simple{date:now:yyyy-MM-dd'T'hh-mm-ss}"
+ "&moveFailed=$simple{file:onlyname}.$simple{date:now:yyyy-MM-dd'T'hh-mm-ss}.failed"
+ "&readLock=idempotent-changed"
+ "&idempotentRepository=#infinispan"
+ "&readLockRemoveOnCommit=true")
.onException(GenericFileOperationFailedException.class)
.onWhen(exchange -> {
Throwable cause = exchange.getException(GenericFileOperationFailedException.class).getCause();
return (cause != null && cause.toString().equalsIgnoreCase("2: No such file"));
}).handled(true)
.logExhausted(true)
.logExhaustedMessageHistory(true)
.log("Could not find file")
.end()
.log("Downloading xml file")
//.to(archiveReceivedFile(sftpFileName))
.split(body().tokenizeXML("ERequest", "ERequests")).streaming()
.inOnly(E_QUEUE)
是的,您可以通过一个路径下载所有文件 你需要
fileName
选项(这样路由将拾取所有文件)+ "&preMove=$simple{file:onlyname}.$simple{date:now:yyyy-MM-dd'T'hh-mm-ss}.processing"
+ "&move=$simple{file:onlyname}.$simple{date:now:yyyy-MM-dd'T'hh-mm-ss}"
+ "&moveFailed=$simple{file:onlyname}.$simple{date:now:yyyy-MM-dd'T'hh-mm-ss}.failed"
include
选项控制要拾取的文件(REGEX以匹配文件名模式)
所以我将其作为$simple{file:gontagator_1.xml,gontagator_2.xml}传递。这种理解正确吗?如果文件夹中有许多文件,我不希望它拾取任何其他文件,但只想获取这两个文件(Gontagrator_1.xml和Gontagrator_2.xml),您可以使用
include
选项限制按文件名模式拾取文件,似乎regex将为->“&include=“+sftpilename+”\u*.xml”当sftpFileName将被标记或将useList
更改为true
,您需要list命令来帮助您在服务器上扫描文件名问题,也许您可以使用下面的解决方法。将$simple{file:onlyname}
替换为$simple{file:onlyname.noext}.xml
两个选项中的move
和moveFailed
。
+ "&include=Gontagrator_(1|2)\.xml"