-
1. Re: How to set value for FTP to lookup multiple file suffixes?
drakenra Jun 9, 2010 10:19 AM (in response to 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 Jun 10, 2010 10:22 AM (in response to drakenra)1 of 1 people found this helpfulLooking at the source code of FtpImpl, this will not work.
You need to derive FtpImpl and override getFileListFromRemoteDir()...
Cheers, Tom.
-
3. Re: How to set value for FTP to lookup multiple file suffixes?
drakenra Jun 11, 2010 3:28 AM (in response to tomeicher)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 Jun 11, 2010 5:45 AM (in response to drakenra)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 Jul 7, 2010 12:32 PM (in response to tomeicher)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.
-
jbossesb-rosetta.jar 1.5 MB
-
-
6. Re: How to set value for FTP to lookup multiple file suffixes?
tomeicher Jul 8, 2010 5:35 AM (in response to drakenra)You can post a feature request at https://jira.jboss.org/secure/CreateIssue!default.jspa
Cheers, Tom.