I have code where I dynamically try to add Endpoints and Endpoint Filters to
CamelContext. But haven't been able to get FileFilter working on File- or
FtpEndpoint's. For example I want to be able to filter only files with given
parameters, for example I want to download files only with txt extension.
Here's the code :
public void testCamel() {
camel = new DefaultCamelContext();
RouteDefinition routeDef = new RouteDefinition();
Endpoint from =
camel.getEndpoint("file:C:\\FtpTestFolders\\FtpOut?delete=true");
//Endpoint from2 =
camel.getEndpoint("quartz://myGroup/myTimerName?cron=0+0/5+*+*+*+?");
//routeDef.setHeader(Exchange.FILE_NAME, new
SimpleExpression("${date:now:yyyyMMdd}.txt"));
routeDef.setHeader("testi", new ConstantExpression("TAMA ON
TESTI"));
Endpoint to =
camel.getEndpoint("file:C:\\FtpTestFolders\\FtpIn?fileName=filename1.txt");
routeDef.from(from).filter().simple("${file:ext} == 'txt'").to(to);
try {
camel.addRouteDefinition(routeDef);
camel.start();
} catch (Exception exp) {
System.out.println("EXCEPTION starting camel : " +
exp.toString());
}
boolean wait = true;
while (wait) {
}
}
}
This works in a way that it routes those files that is defined in the filter
but it removes all files from the source endpoint. I read about
GenericFileFilter but how can I add it programmatically to camel context ? I
would like to be able to define per route programmatically which filter
parameter I would like to use.
Thank you.
Your help would be greatly appreciated.
Best Regards Tuomas
--
View this message in context:
http://camel.465427.n5.nabble.com/Adding-File-name-filter-for-RouteEndpointDefinition-tp4968230p4968230.html
Sent from the Camel - Users mailing list archive at Nabble.com.