I am trying to write a camel route that reads a database table to get the list of absolute file paths and then copy those files to another folder. However only the file path is created as content instead of the original content.
from("timer://testDataGen?repeatCount=1")
.to("sql:" + positionSql + "?dataSource=dataSource")
.split(body())
.to("file://" + positionlistDir )
.log("Finished copying the list of Files.")
Please let me know what am i missing here to convert an absolute file path to an actual file.
Update #1.
Below snippet is invoking the pollEnrich(). But instead the pollEnrich() is copying the no of files which is equal to the no of rows returned by the sql and not according to the file name from the previous exchange.
String positionListSqlOptions = "?dataSource=dataSource";
// String positionSrcDirOptions = "?noop=true&delay=500&readLockMarkerFile=false&fileName=${header.positionFileToBeCopied}";
String positionSrcDirOptions = "?noop=true&delay=500&readLockMarkerFile=false&fileName=${body}";
String positionStagingDirOptionsForWriting = "?doneFileName=${file:name}.DONE";
from("timer://testDataGen?repeatCount=1")
.to("sql:" + positionListSql + positionListSqlOptions)
.split(body())
\\ Getting the column value from the resultset which is a LinkedCaseInsensitiveMap and storing in the body
.process(new positionFeederProcessor())
.setHeader("positionFileToBeCopied", body())
.pollEnrich("file://" + positionSrcDir + positionSrcDirOptions)
// .pollEnrich().simple("file://" + positionSrcDir + positionSrcDirOptions)
.to("file://" + positionStagingDir + positionStagingDirOptionsForWriting)
.log("Finished copying the list of Files.");
I am still unable to get the actual file name passed to the pollingEnrich() endpoint. I tried extracting it from body as well as through a header too. What could have gone wrong.
Well, Finally I was able to do this without using pollEnrich() at all.
And here are the processors.