4 Replies Latest reply on Apr 23, 2014 11:31 AM by vamshi.chilukamarri

    fs-provider - can sequence of files being read be controlled?

    stsc

      Is there a way to govern how the fs-provider should pick up files from the directory it is configured to listen to? E.g. file creation time ascending/descending? By lexical order ascending/decending?

       

      Is the reading-sequence deterministic at all?

       

      In my case, the day to day work is not an issue, but if the ESB has been taken down for a relative long period of time, a lot of files may have accumulated, and they need to be read into the system in the same order as they arrived (or at least as close as possible).

        • 1. Re: fs-provider - can sequence of files being read be controlled?
          tcunning

          Steffen,

           

          The fs-provider provides a mechanism to filter out files (java.io.FileFilter), but not to ordering the files.      Files are read in the order that java.io.File.listFiles(filter) presents, which according to the JavaDoc guarantees no specific ordering method.

           

          I think you could probably work around this.  If you extend AbstractFileGateway you can define how getFileList() works - basically if all you want to do is add ordering, you could copy the entirety of FileGatewayListener.java and just change the filterFiles method to give yourself some file ordering.     You would also have to change FsListenerMapper.java to recognize your new file gateway (or provide your own mapping).

           

          You could also work around the whole problem by providing a staging directory with cron scripts to move small numbers of files into the file gateway listener directory, depending on how many files are in there at the current time.

           

          --Tom

          • 2. Re: fs-provider - can sequence of files being read be controlled?
            vamshi.chilukamarri

            Hi  sschmidt

             

            Have you had a chance to implement your own FileGatwayListener as Tom suggested. Could you please share your thoughts on how your approach was to override and configure it to use this new custom class ?

             

            I am in similar situation as I have to filter files based on the filename, I am refraining from using external cron job at this point if it can be solved inside ESB.

             

            Thanks

            Vamshi

            • 3. Re: fs-provider - can sequence of files being read be controlled?
              tcunning

              Vamshi,

               

              There isn't a way to solve this inside of the ESB, other than to change the code to filterFiles() like I cited above.    You could do this through AOP if you wanted, if you didn't want to alter any ESB code.

               

              --Tom

              • 4. Re: fs-provider - can sequence of files being read be controlled?
                vamshi.chilukamarri

                Thanks Tom for the reply. Can you please guide me what will be the approach for AOP ? never worked on that.

                Appreciate your help

                Thanks