Announcement Announcement Module
Collapse
No announcement yet.
Need to read files in a sequential order. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Hi Senior members, please reply for my problem.

    Comment


    • #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

      Comment


      • #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

        Comment


        • #5
          http://static.springsource.org/sprin...istFilter.html

          Comment


          • #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

            Comment

            Working...
            X