A camel route is used to handle multi-row csv files. The route from is configured with the query parameter moveFailed
. This all basically works. But the rows are processed one by one and in case of error, it route shall not stop but shall continue. Afterwards, the file should be moved to failed if any error has occurred.
Question: How to trigger “move to fail” in the code?
The code looks basically like this:
from("file:/C:/dev/_import?moveFailed=failed&delete=true&readLock=changed")
.onException(Throwable.class)
.setHeader("fileFailedPartly").simple("true")
.log(LoggingLevel.ERROR, "${exception.stacktrace}")
.log(LoggingLevel.ERROR, "Exception occurred when reading row - continue with file ${header.CamelFileName}")
.continued(true)
.end()
.bean(CsvParser.class)
.split().body()
.log(LoggingLevel.INFO, "Sending row ${header.CamelSplitIndex}++ of ${header.CamelSplitSize}")
.delay(1000)
.bean("sender","send")
.end()
.choice()
.when(simple("${header.fileFailedPartly} == true"))
.log(LoggingLevel.INFO, "File ${header.CamelFileName} partly failed. Move to failed.")
//trigger move to failed
.end();
I may should add that the application is quarkus based, thus quarkus-camel is used.