The application which i am working on has an Integration Layer build using Spring Integration 2.5, It tries to pull a CSV file from FTP server using FTP adapter and drops it on to local server which is polled by
File adapter. So as soon as file is downloaded by ftp the file adapter passes it on to Splitter wherein the CSV file is split into separate records and send to downstream for further processing.
The issue occurs which splitter is some times does not see the file although the file is downloaded. Below are the config details and that piece of code from splitter which tried to check if the file exists or throw user defined exception.
Code:<ftp:inbound-channel-adapter id="ftpInbound" channel="ftpChannel" session-factory="ftpClientFactory" filename-regex="${ftp.server.remotefilename}" auto-create-local-directory="true" delete-remote-files="false" remote-directory="${ftp.server.remotefolder}" local-directory="file:${ftp.server.localfolder}"> <si:poller ref="FTPPoller"></si:poller> </ftp:inbound-channel-adapter> <si:channel id="ftpChannel"> <si:queue /> </si:channel> <file:inbound-channel-adapter id="fileInboundAdapter" channel="fileIn" directory="file:${ftp.server.localfolder}" filename-pattern="${ftp.server.localfilename}" auto-create-directory="true" prevent-duplicates="false"> <si:poller ref="filePoller"></si:poller> </file:inbound-channel-adapter> <si:channel id="fileIn" /> <si:splitter input-channel="fileIn" output-channel="csvRowsIn" ref="inboundFileRowSplitter" method="extractRows" />Code:public class InboundFileRowSplitter { @Splitter public Collection<String[]> extractRows( @Headers Map<String, Object> headers, File keywordFile ) { .................................................. .................................................. .................................................. .................................................. .................................................. return processKeywordsFile( keywordFile ); } private Collection<String[]> processKeywordsFile( File keywordFile ) { try { if (keywordFile.exists()) { .................................................. .................................................. .................................................. .................................................. } else { throw new ResourceLoaderException( "............................" ); } } catch (Exception e) { .................................................. } finally { .................................................. } }


Reply With Quote