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

Talend ESB Mediation Developer Guide

Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
Design and Development
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"/>

   <from uri="   //
   <to uri="bean:processInbox"/>