I am creating a simple file transfer utility where based on user input I search the file in the folder and transfer the matched file to destination. The problem
is camel is moving all the files which are not matching to .camel folder i dont want that to happen below is my snippet.
from("file:C:\input?noop=true;").
filter(header(Exchange.FILE_NAME)
.contains("xyz")).split(body().tokenize("n")).
streaming().bean(LineParser.class, "process").
to("file:"+ Constants.getMapping().get(argumentName)+"?
fileExist=Append");
Thanks in advance !!
2
Answers
Remove semicolon after noop=true and property will start working deprecating moving processed files to .camel
Processed files are all files processed without exception so even matched files will remain in C:input directory too. When you use noop=true default idempotent repository is in-memory. So after you restart your app already processed files will be processed again. So you need create your own not in-memory idempotent repo.
Check out the file component consumer options: http://camel.apache.org/file2.html. You should be able to use the “filter” or “filterFile” option in the from uri. These will filter at the endpoint, as Claus mentions above. The filterFile will be more concise if you are able to use the Simple language:
Otherwise, you could create a filter bean to handle the filtering and use filter option to reference that bean. Notice that the filter().contains() is no longer needed: