Filtering using ANT path matcher - 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

The ANT path matcher is a filter that is shipped out-of-the-box in the camel-spring jar. So you need to depend on camel-spring if you are using Maven. The reason is that we leverage Spring's AntPathMatcher to do the matching.

The file paths are matched with the following rules:

  • ? matches one character

  • * matches zero or more characters

  • ** matches zero or more directories in a path

The sample below demonstrates how to use it:

<camelContext xmlns="http://camel.apache.org/schema/spring">
   <template id="camelTemplate"/>
   <!-- use myFilter as filter to allow setting ANT paths for which -->
   <!-- filesto scan for -->
   <endpoint id="myFTPEndpoint" 
      uri="ftp://admin@localhost:20123/antpath?password=admin&
      recursive=true&delay=10000&initialDelay=2000&filter=#myAntFilter"/>

    <route>
       <from ref="myFTPEndpoint"/>
       <to uri="mock:result"/>
    </route>
</camelContext>

<!-- we use the AntPathMatcherRemoteFileFilter to use ant paths for -->
<!-- includes and excludes -->
<bean id="myAntFilter" 
   class="org.apache.camel.component.file.AntPathMatcherGenericFileFilter">
   
   <!-- include and file in the subfolder that has day in the name -->
   <property name="includes" value="**/subfolder/**/*day*"/>
   <!-- exclude all files with bad in name or .xml files. -->
   <!-- Use comma to separate multiple excludes -->
   <property name="excludes" value="**/*bad*,**/*.xml"/>
</bean>