Using Spring Integration, can we sort files and then process them?
A unique requirement for our integration is that we FTP files from a vendor - and then, we need to process them in a specific order (e.g sort by fileName).
An FTP In-Bound adapter would notify a service activator to process the file, but the order is not guaranteed in this case, and I need to process files in order.
Is there any way I can accomplish this using a custom filter or selection strategy?
Tried implementing a simple filter
That attempts sorting. I also return the file list as sorted.
[Assume that the files are of .txt extension say 0.txt, 1.txt and so on]
Custom Filter Input: 0,1,10,2,3.
Custom Filter Output: 0,1,2,3,10
However, the service activator's (handleFile) still gets activated for the files
in sequence 0,1,10,2,3. It appears to ignore the sorted list supplied by my custom filter.
Also, when my unit test runs, it displays the output for FileReadingMessageSource as Created Message for 0, followed by Created Message for 1, followed by Created Message for 10 and so on.
Configurations are standard - file inbound adapter with id, directory and filter attribute set. The filter does get invoked and does the sorting. However, the sorted list is ignored by SI, and my service activator gets invoked in the same input order.
Any help would be appreciated.
Created a JIRA issue for tracking.
https://jira.springsource.org/browse/INT-1857