Reputation: 5957
I have two file names in following format:
Gontagrator_1.xml
Gontagrator_2.xml
As of now i am picking just Gontagrater_1.xml and rename it to processing and failed once done.
+ "&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"
Now Gontagrator_2 comes into picture. It is suggested to create separate routes for both.
Can we download both in one route and rename accordingly? If yes, what values i need to pass?
Update1: There are multiple files with different names but i need to use both above file names only
update 2: Whole from component is:
"{{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)
Upvotes: 1
Views: 2004
Reputation: 1879
Yes, you can download all files in one route.
You need to
fileName
option (such that the route will pick all file)Use file expression language (file:onlyname) to refer to filename currently handled by Camel SFTP component
+ "&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"
Use include
option to control file to be picked up (REGEX to match file name pattern)
+ "&include=Gontagrator_(1|2)\.xml"
Upvotes: 2