Jun 20th, 2012, 02:08 AM
Need to read files in a sequential order.
By using Spring integration, I need to read the files from a directory in a sequential order.
Example: file name will be like
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.
Aug 7th, 2012, 11:57 PM
Hi Senior members, please reply for my problem.
Aug 8th, 2012, 04:43 AM
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.
Aug 9th, 2012, 12:55 AM
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
Aug 9th, 2012, 01:48 AM
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..
Tags for this Thread