INT-4215: Add ChainFileListFilter

JIRA: https://jira.spring.io/browse/INT-4215
Fixes GH-1998 (https://github.com/spring-projects/spring-integration/issues/1998)

Just make an `CompositeFileListFilter` extension which chains result of the previous filter to the next

**Cherry-pick 4.3.x**
This commit is contained in:
Artem Bilan
2017-01-25 13:00:19 -05:00
committed by Gary Russell
parent 9dfc7f4671
commit 35a633d304
6 changed files with 105 additions and 7 deletions

View File

@@ -105,6 +105,20 @@ to, say, network glitches.
</bean>
----
Starting with _version 4.3.7_ a `ChainFileListFilter` (an extension of `CompositeFileListFilter`) has been introduced to allow scenarios when subsequent filters should only see the result of the previous filter.
(With the `CompositeFileListFilter`, all filters see all the files, but only files that pass all filters are passed by the `CompositeFileListFilter`).
An example of where the new behavior is required is a combination of `LastModifiedFileListFilter` and `AcceptOnceFileListFilter`, when we do not wish to accept the file until some amount of time has elapsed.
With the `CompositeFileListFilter`, since the `AcceptOnceFileListFilter` sees all the files on the first pass, it won't pass it later when the other filter does.
The `CompositeFileListFilter` approach is useful when a pattern filter is combined with a custom filter that looks for a secondary indicating file transfer is complete.
The pattern filter might only pass the primary file (e.g. `foo.txt`) but the "done" filter needs to see if, say `foo.done` is present.
Say we have files `a.txt`, `a.done`, and `b.txt`.
The pattern filter only passes `a.txt` and `b.txt`, the "done" filter will see all three files and only pass `a.txt`.
The final result of the composite filter is only `a.txt` is released.
NOTE: With the `ChainFileListFilter`, if any filter in the chain returns an empty list, the remaining filters are not invoked.
*Directory scanning and polling*
The `FileReadingMessageSource` doesn't produce messages for files from the directory immediately.

View File

@@ -169,6 +169,11 @@ This applies when the outbound gateway returns an `InputStream` or the new (S)FT
Also a new `markers-json` options has been introduced to convert `FileSplitter.FileMarker` to JSON `String` for relaxed downstream network interaction.
See <<file-splitter>> for more information.
===== File Filters
A new `ChainFileListFilter` is provided as an alternative to `CompositeFileListFilter`.
See <<file-reading>> for more information.
==== AMQP Changes
===== Content Type Message Converter