Results 1 to 6 of 6

Thread: Need to read files in a sequential order.

  1. #1
    Join Date
    Feb 2012
    Posts
    19

    Question 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

  2. #2
    Join Date
    Feb 2012
    Posts
    19

    Default

    Hi Senior members, please reply for my problem.

  3. #3
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    637

    Default

    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

  4. #4
    Join Date
    Sep 2011
    Posts
    28

    Default

    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

  5. #5
    Join Date
    Sep 2011
    Posts
    28

  6. #6
    Join Date
    Sep 2011
    Posts
    28

    Default

    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
  •