4 Replies Latest reply on Jul 9, 2008 10:30 AM by lcurry

    servicemix-ftp and unusual File Filtering rules

    lcurry

      We have a directory where the ftp-poller will pull files. The files are organized in a strange way (based on legacy system that can't be changged), for example the directory will contain the following files:

       

      a.xml

      done_a.xml

      b.xml

      done_b.xml

      c.xml

       

      The presense of the "done_*.xml" indicates the corresponding file is ready to download. So in the above case the ftp-poller should only ftp the following:

       

      a.xml

      b.xml

       

      It should not get "c.xml" Because there is no "done_c.xml".

      Does this make sense?

      Is there any way to implement this type of thing with the ftp-poller? I had a look at the FileFilter but I don't think it will work considering this interface must make its decision on a file-by-file basis, whereas the above algorithm must have a view of all the file names in order to make its decision. Any ideas appreciated.

      Thanks,

      -Lowry

        • 1. Re: servicemix-ftp and unusual File Filtering rules
          gertv

          Lowry,

           

           

          You could use a FileFilter implementation if you provide it with it's own connection to the same FTP server, using e.g. another <ftp:pool> to provide the connections.  Just wire them together using plain Spring syntax in your xbean.xml file.

           

          Your FileFilter's accept() method can than access the same FTP server to see if the matching done_ file is there before return true to the FTP poller.

           

           

          Regards,

           

          Gert

          • 2. Re: servicemix-ftp and unusual File Filtering rules
            lcurry

            I'm not sure i understand. I don't see <ftp:pool> documented anywhere. What attributes are available to set? What servicemix class does this correspond to? I assume my logic would go in custom Filter class accept() method. Here i'd need to utilize the standard FTPClient, etc. to connect back to the ftp server and do things on it.

            Any xbean snippets that give the gist of what i'd be doing. Even if different bean class i could extrapolate.

            Thanks,

            • 3. Re: servicemix-ftp and unusual File Filtering rules
              gertv

              Lowry,

               

              The &lt;ftp:pool/&gt; element creates an org.apache.servicemix.ftp.FTPClientPool instance.  If you give it an id, you can reference it from you CustomFilter using plain Spring syntax.

               

              Probably missing some details, but just to give you an idea...

               

                <ftp:poller filter="#CustomFilter"/>
                
                <bean id="CustomFilter" class="my.custom.FilterImpl">
                   <property name="pool"><ref bean="ConnectionPool"></ref>
                </bean>
                
                <ftp:pool id="ConnectionPool" host="server"
                          username="myUser" password="myPassword"></ftp:pool>
              

               

              Regards,

               

              Gert

               

              Edited by: gertv on Jun 20, 2008 6:27 AM

              • 4. Re: servicemix-ftp and unusual File Filtering rules
                lcurry

                thanks!