Reputation: 1645
I have an application and periodically files are coming in one folder. There is always two files that comes, one is named ACK + Name of the file and is empty, and the other one is just the name of the file (this one is the data file).
I heard from some people that there is a way in Camel to process my file by detecting the ACK.
What I'm current doing is to detect the ACK file and then trigger a process that will get the data file and process it. But with this I can't have working unit test for my code.
But if it's possible I'd prefer to have a route that detect my ACK but trigger the process with the data file.
Is this possible ?
Here is my actual route:
@Component
public class MyRoute extends RouteBuilder {
public static final String ROUTE_NAME = "myRoute";
private final Processor myProcessor;
@Autowired
public MyRoute(@Qualifier("my.processor") Processor myProcessor) {
this.myProcessor= myProcessor;
}
@Override
public void configure() throws Exception {
from("file://{{data.input.dir}}?moveFailed=errors&delete=true&include=ACK.*").routeId(ROUTE_NAME)
.choice()
.when(header("CamelFileName").startsWith("ACK"))
.process(myProcessor)
.end();
}
}
EDIT:
Found the solution using the doneFileName
option
Upvotes: 0
Views: 108
Reputation: 7005
As you found out by yourself, Camel can handle this automatically with the doneFileName
option.
You don't have to process the ACK file at all.
But as a consequence: if an ACK file is missing, the data file is not processed since Camel treats datafiles without done-file as still in process of transfer/writing.
Upvotes: 1