Below is my code:
from("quartz2:report?cron=" + cronExpression)
.routeId("jms:queue:test")
.setHeader("CURRENT_TIME", simple("${date:now:MM-dd-yyyy HH:mm:ss.S}"))
//Writing column names for report to the file
.setBody()
.simple(summaryHeaders)
.transform(body().append("\n"))
.to("file:" + filePath + "?fileName="+scheduledFileName+"${date:now:MM-dd-YYYY}.csv&fileExist=append")
.to("sql:" + dataSummaryQuery + "?dataSource=#dataSource")
.log(LoggingLevel.INFO, "Summary query executed")
.marshal(csvFormat)
.to("file:" + filePath + "?fileName="+scheduledFileName+"${date:now:MM-dd-YYYY}.csv&fileExist=append")
.log(LoggingLevel.INFO, "Report written to file")
.setBody()
.simple(fileHeaders)
.transform(body().append("\n"))
.to("file:" + filePath + "?fileName="+scheduledFileName+"${date:now:MM-dd-YYYY}.csv&fileExist=append")
.to("sql:" + dataExtractionQuery + "?dataSource=#dataSource")
.log(LoggingLevel.INFO, "data query executed")
.marshal(csvFormat)
.to("file:" + filePath + "?fileName="+scheduledFileName+"${date:now:MM-dd-YYYY}.csv&fileExist=append");
Till the above code, everything is work fine and all the required data is in the file. When I try to move the file to a different location, the moved file only has the data from the dataextractionquery above. The previous data are not in the file. What is happening here? How can I move the file with all the data added?
Code to move the file:
from("file:" + filePath + "?fileName="+scheduledFileName+"${date:now:MM-dd-YYYY}.csv&fileExist=append")
.to("file:" + filePath + "?fileName=temp/");
If I do not move the file, I have all the data in the file