Hi,
I am new to camel. My requirement is to read a huge file (> 100 KB) and
process it. If process fails due to some reason, file should be moved to
error folder. since it is a huge file I am using split() with streaming().
Below is my route definition.
onException(Exception.class).to("direct:handleFailure");
from("file:C:/UFM/test?delay=10000&readLock=changed&move=processed&moveFailed=error")
.log("Starting to process file: ${header.CamelFileName}")
.setProperty("UfmProcessLogId", method(ufmProcessService,
"logUFMProcessStart(${header.CamelFileName})"))
.split(body().tokenize("\n"), new
UFMAggregationStrategy()).streaming().stopOnException()
.to("direct:processUFM")
.end()
.bean(ufmProcessService,
"logUFMProcessSuccess(${property.UfmProcessLogId},
${property.CamelSplitSize})")
.log("End of process file: ${header.CamelFileName}");
from("direct:processUFM")
.filter(body().startsWith(TRANSACTION_PREFIX))
.unmarshal().bindy(BindyType.Fixed, UFMVehiclePassage.class)
.to("stream:out");
from("direct:handleFailure")
.bean(ufmProcessService,
"logUFMProcessFailure(${property.UfmProcessLogId},
${property.CamelSplitIndex}, ${body}, ${exception.stacktrace})");
When the process failed, file is failed to move into error folder due to
below exception.
Caused by: java.io.IOException: Renaming file from:
C:\UFM\test\FDOT9010UFMSample1.txt to:
C:\UFM\test\error\FDOT9010UFMSample1.txt failed due cannot delete from file:
C:\UFM\test\FDOT9010UFMSample1.txt after copy succeeded
File is being successfully moved to error folder when streaming() is removed
or if I use convertBodyToType(String).
Since it is huge file, I have to use streaming() and I can't use
convertBodyToType(String) because it loads whole file into memory which I
want to avoid in the first place.
Please suggest me if there is any solution for this.
OS: Windows
Camel: 2.11.1 on JDK7.
Thanks & Regards,
Srinivas Atluri
--
View this message in context:
http://camel.465427.n5.nabble.com/moveFailed-is-failing-when-streaming-is-on-tp5737065.html
Sent from the Camel - Users mailing list archive at Nabble.com.