GH-9869: Introduce AbstractRecentFileListFilter strategy

Fixes: https://github.com/spring-projects/spring-integration/issues/9869

Currently, FileListFilters on the last modified attribute of a file are limited to the use case of discarding files that are too young.
It would be great to have a filter implementation which would accept files which are not old enough.

* Implement `AbstractRecentFileListFilter` for all the supported file protocols
This commit is contained in:
Artem Bilan
2025-02-27 10:59:20 -05:00
parent 7680e02cbb
commit 8bfb5d248f
14 changed files with 517 additions and 2 deletions

View File

@@ -138,7 +138,12 @@ The `CompositeFileListFilter` also implements a `DiscardAwareFileListFilter` and
NOTE: Since `CompositeFileListFilter` matches the files against all delegates, the `discardCallback` may be called several times for the same file.
Starting with version 5.1, the `FileReadingMessageSource` doesn't check a directory for existence and doesn't create it until its `start()` is called (typically via wrapping `SourcePollingChannelAdapter`).
Previously, there was no simple way to prevent an operation system permissions error when referencing the directory, for example from tests, or when permissions are applied later.
Previously, there was no simple way to prevent the operating system permissions error when referencing the directory, for example from tests, or when permissions are applied later.
In opposition to the `LastModifiedFileListFilter`, a `RecentFileListFilter` strategy has been introduced starting version 6.5.
It is an extension for local file system of the `AbstractRecentFileListFilter`.
By default, it accepts files which are not older than 1 day.
See its other implementations for respective remote file protocol.
[[message-headers]]
== Message Headers

View File

@@ -103,6 +103,8 @@ This filter can be configured with an `age` property so that only files older th
The age defaults to 60 seconds, but you should choose an age that is large enough to avoid picking up a file early (due to, say, network glitches).
Look into its Javadoc for more information.
In contrast, starting with version 6.5, an `FtpRecentFileListFilter` has been introduced to accept only those files which are not older than provided `age`.
[[more-on-file-filtering-and-incomplete-files]]
== More on File Filtering and Incomplete Files

View File

@@ -100,6 +100,8 @@ This filter can be configured with an `age` property so that only files older th
The age defaults to 60 seconds, but you should choose an age that is large enough to avoid picking up a file early (due to, say, network glitches).
Look into its Javadoc for more information.
In contrast, starting with version 6.5, an `SftpRecentFileListFilter` has been introduced to accept only those files which are not older than provided `age`.
[[more-on-file-filtering-and-large-files]]
== More on File Filtering and Large Files

View File

@@ -162,6 +162,8 @@ This filter can be configured with an `age` property so that only files older th
The age defaults to 60 seconds, but you should choose an age that is large enough to avoid picking up a file early (due to, say, network glitches.
Look into its Javadoc for more information.
In contrast, starting with version 6.5, an `SmbRecentFileListFilter` has been introduced to accept only those files which are not older than provided `age`.
[[configuring-with-the-java-dsl]]
=== Configuring with the Java DSL

View File

@@ -61,4 +61,11 @@ See xref:mqtt.adoc[MQTT Support] for more information.
The `KafkaMessageSource` and `KafkaMessageDrivenChannelAdapter` now generate `MessageHeaders.ID` and `MessageHeaders.TIMESTAMP` headers by default as the rest of Spring Integration channel adapters.
The behavior can be restored to the previous with injection of the `MessagingMessageConverter` with default settings.
See xref:kafka.adoc[Apache Kafka Support] for more information.
See xref:kafka.adoc[Apache Kafka Support] for more information.
[[x6.5-file-filter-changes]]
== The Recent File Filter Support
The `AbstractRecentFileListFilter` strategy has been introduced to accept only those files which are not old enough according to the provided `age`.
The respective implementations are provided: `RecentFileListFilter`, `FtpRecentFileListFilter`, `SftpRecentFileListFilter` and `SmbRecentFileListFilter`.
See xref:file/reading.adoc[Reading Files] for more information.