6 Replies Latest reply on Jul 8, 2010 5:35 AM by tomeicher

    How to set value for FTP to lookup multiple file suffixes?

    drakenra

      Hi everyone!

       

      I am starting to work with JBoss ESB. I am using helloworld_ftp_action-example project to start with and I'm trying to get it to work, so that it accepts more than one input suffixes (example have the value of ".dat") to process.

       

      Here is code snip from the example:

       

      <providers>
      <ftp-provider name="FTPprovider" hostname="@FTP_HOSTNAME@">
      <ftp-bus busid="helloFTPChannel">
      <ftp-message-filter username="@FTP_USERNAME@" password="@FTP_PASSWORD@" passive="false" directory="@FTP_DIRECTORY@" input-suffix=".dat" work-suffix=".esbWorking" post-delete="false" post-rename="true" post-suffix=".COMPLETE" error-delete="false"
      error-suffix=".HAS_ERROR" />
      </ftp-bus>
          
      </ftp-provider>
      (so on...)


      I have tried to change input-suffix value like ".cvs,.xls,.doc", but it doesn't seem to work... Do anyone know what's the seperator character or something like that? I can't find any help from documents.

       

      Any help would be appreciated. Thank you.

        • 1. Re: How to set value for FTP to lookup multiple file suffixes?
          drakenra
          Code snip:
          <ftp-provider name="FTPprovider" hostname="@FTP_HOSTNAME@">
          <ftp-bus busid="helloFTPChannel">
          <ftp-message-filter username="@FTP_USERNAME@" password="@FTP_PASSWORD@" passive="false" directory="@FTP_DIRECTORY@" input-suffix=".dat" work-suffix=".esbWorking" post-delete="false" post-rename="true" post-suffix=".COMPLETE" error-delete="false"
          error-suffix=".HAS_ERROR" />
          </ftp-bus>
          </ftp-provider>
          • 2. Re: How to set value for FTP to lookup multiple file suffixes?
            tomeicher

            Looking at the source code of FtpImpl, this will not work.

            You need to derive FtpImpl and override getFileListFromRemoteDir()...

            Cheers, Tom.

            1 of 1 people found this helpful
            • 3. Re: How to set value for FTP to lookup multiple file suffixes?
              drakenra

              Thank you for your reply, it was helpful.

               

              I checked the FtpImpl-class and you were right. It only accept one suffix. I did as you suggested, I extended FtpImpl-class and overrided getFileListFromRemoteDir-method. The next problem is how can I tell remote gateway listener "org.jboss.soa.esb.listeners.gateway.RemoteGatewayListener"- and "org.jboss.internal.soa.esb.couriers.helpers.FtpFileHandler"-class to use my class instead of JBoss FtpImpl-class? Any suggestions for this ?

               

              Here is my quick overrided method, which could do the trick perhapse but could be a little slow if there is many suffix defined.

               

               

              @Override
              public String[] getFileListFromRemoteDir(String p_sSuffix) throws RemoteFileSystemException, IOException {
                   final String DELIMITER = ";";
                   boolean bMultiSuffixes = (p_sSuffix != null && p_sSuffix.indexOf(DELIMITER) > -1 ? true : false);
                   String sSuffix = (null == p_sSuffix) ? "*" : "*" + p_sSuffix;
              
                   try {
                        changeRemoteDirectory();
                        if (bMultiSuffixes) {
                             String[] suffixes = p_sSuffix.split(DELIMITER);
                             List<String> listFiles = new LinkedList<String>();
                             for (String suffix : suffixes) {
                                  String[] files = m_oConn.listNames("*" + suffix);
                                  if (files != null && files.length > 0) {
                                       listFiles.addAll(Arrays.asList(files));
                                  }
                             }
                             return listFiles.toArray(new String[0]);
                        } else {
                             return m_oConn.listNames(sSuffix);
                        }
                   } catch (final IOException ioe) {
                        throw new RemoteFileSystemException(ioe);
                   }
              }
              


              • 4. Re: How to set value for FTP to lookup multiple file suffixes?
                tomeicher

                Yes, ESB could really be a little bit friendlier to extensions like that.

                You'll probably end up having to patch RemoteFileSystemFactory to use your new FtpImpl.

                 

                Personally, I'd not bother with ftp listeners and do it from my action action, like...

                 

                <service ...
                    <listeners>
                     <scheduled-listener ... event-processor="my.event.processor.MyPollFtpServer">
                ...

                     </scheduled-listener>
                    </listeners>
                    <actions>
                      <action ...

                 

                With the MyPollFtpServer like

                 

                    @Override
                    public Message composeMessage() throws SchedulingException
                    {

                        MyFtpImpl myftpimpl = new MyFtpImpl()

                        ...

                        if (newFiles) {

                            return newFiles; }

                        } else {

                            return null;

                       }

                        }

                then you don't have to patch ESB code but can just add your classes in your esb file.

                 

                Cheers, Tom.

                • 5. Re: How to set value for FTP to lookup multiple file suffixes?
                  drakenra

                  Thanks for the suggestions. Sorry for the late reply.

                   

                  I got it to work by replacing "C:\Program Files\jboss-5.1.0.GA\server\default\deployers\esb.deployer\lib\jbossesb-rosetta.jar"-file with my modified FtpImpl-file using my above code. I can do like:

                  <ftp-message-filter directory="" error-delete="false" input-suffix=".doc;.xls;.txt;.rtf" password="password" post-delete="true" protocol="ftp" username="username"/>

                   

                  If JBoss ESB team is reading this post. Could you please patch FtpImpl-file with the above code to the next release, thanks?

                   

                  Here is the replaced file with modified changes if anyone else needs it also.

                  • 6. Re: How to set value for FTP to lookup multiple file suffixes?
                    tomeicher

                    You can post a feature request at https://jira.jboss.org/secure/CreateIssue!default.jspa

                    Cheers, Tom.