Filter using org.apache.camel.component.file.GenericFileFilter - 6.3

Talend ESB Mediation Developer Guide

EnrichVersion
6.3
EnrichProdName
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
task
Design and Development
EnrichPlatform
Talend ESB

Camel supports pluggable filtering strategies. This strategy it to use the built in org.apache.camel.component.file.GenericFileFilter in Java. You can then configure the endpoint with such a filter to skip certain filters before being processed.

In the sample we have build our own filter that only accepts files starting with report in the filename.

public class MyFileFilter implements GenericFileFilter {
   public boolean accept(GenericFile file) {
      // we only want report files 
      return file.getFileName().startsWith("report");
   }
}

And then we can configure our route using the filter attribute to reference our filter (using # notation) that we have defined in the Spring XML file:

<!-- define our filter as a plain Spring bean -->
<bean id="myFilter" class="com.mycompany.MyFileFilter"/>

<route>
   <from uri="ftp://someuser@someftpserver.com?password=secret   //
      &amp;filter=#myFilter"/>
   <to uri="bean:processInbox"/>
</route>