Anypoint Connectors for File, FTP, and SFTP provide an On New or Updated File operation that polls a directory for files that have been created or updated. A message is generated for each file that is found.
The following strategies determine that a file is new:
-
Set the Auto delete field to True to delete each file after it is processed, which causes all files obtained in the next poll to be considered new.
-
Set the Move to directory field to move each file to a different directory after it is processed, which achieves the same effect as Auto delete but without erasing the file.
-
Set the Watermark field to pick only files that have been created or updated after the last poll was executed.
You can also use a matcher for additional filtering of files.
Example: File Listener (On New File Trigger)
<flow name="onNewFile">
<file:listener config-ref="file" directory="test-data/in" autoDelete="true">
<scheduling-strategy>
<fixed-frequency frequency="1000"/>
</scheduling-strategy>
</file:listener>
<flow-ref name="processFile" />
</flow>