-
Jun 20th, 2012, 02:08 AM
#1
Need to read files in a sequential order.
Hi,
By using Spring integration, I need to read the files from a directory in a sequential order.
Example: file name will be like
abc_001.csv
abc_002.csv
abc_003.csv
abc_005.csv
abc_006.csv
In the above case: abc_004.csv is still not available in the input directory. So need to process abc_001.csv, abc_002.csv, abc_003.csv then wait for abc_004.csv. Once abc_004.csv is available in the input directory then start processing abc_004.csv, abc_005.csv, abc_006.csv.
Thanks
DevSpring
-
Aug 7th, 2012, 11:57 PM
#2
Hi Senior members, please reply for my problem.
-
Aug 8th, 2012, 04:43 AM
#3
Hello
The first one: don't try to solve your issue with inbound-channel-adapter. It's just a component which convert end-objects to the Messages to allow them to go through messaging system.
Can you look at your files as chain and group them with some correlationId?
Do you have any possibility to get the number of files?
If it is posible what you need is just <resequencer>:
1. You receive all avaliable Messages from directory
2. Enrich each of them with headers CORRELATION_ID, SEQUENCE_NUMBER & SEQUENCE_SIZE
3. Place them into <resequencer>
4. And output Message to some your business channel.
5. They will be here in the expected order.
Take care,
Artem
-
Aug 9th, 2012, 12:55 AM
#4
Implement a custom filter for the file inbound adapter which will get executed. lOOK at FileLISTFilter. Try to put your own logic on what files needs to be picked etc like a sorting algorithihm which picks up sequentially. Hope that helps
-
Aug 9th, 2012, 01:10 AM
#5
-
Aug 9th, 2012, 01:48 AM
#6
You also might want to check the last date and time stamp of the file when it was picked up in your filter. Compare the file.getLostModified time with whatever time you want to compare. If the condition is true then send the file else no. So now if abc001.csv, abc002.csv was already picked up they won't be send and abc0003.csv came in the directory then only that specific file will be picked up. Thanks to filter attribute on file inbound adapter which gives up ability to write our own custom logic on what files needs to be picked up..
http://static.springsource.org/sprin.../#file-reading
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules