spring integration - ftp outbound channel adapter not transferring same files -


i have following configuration in application. writing file ftp folder , reading ftp location.

  1. i want take file ftp location , save in directory decided dynamically. done using 2 chained channel adapters. ftp nbound channel adapter picks file, puts in local directory , file inbound channel adapter picks file , puts in final destination. need filter old files process. ftp inbound channel adapter custom filter gave me ftpfile object in filtering method. object gives last modified date rather date file put in filter. due limitation had use file inbound channel adapter well.
  2. since not know how generate source directory dynamically, using plain java code copy required file local-directory ftp outbound channel picks , puts on ftp location.

this configuration:

    <bean id="filenamegenerator" class="com.polling.util.filenamegenerator"/>        <int-file:inbound-channel-adapter id="filesin" directory="file:${paths.root}" channel="abc" filter="compositefilter"  >         <int:poller id="poller" fixed-rate="500" />      </int-file:inbound-channel-adapter>     <int:channel id="abc"/>     <bean id="compositefilter" class="org.springframework.integration.file.filters.compositefilelistfilter">         <constructor-arg>             <list>                 <!-- ensures file whole before processing -->                 <bean class="com.polling.util.customfilefilter"/>                 <!-- ensures files picked once directory -->                 <bean class="org.springframework.integration.file.filters.acceptoncefilelistfilter" />             </list>         </constructor-arg>     </bean>      <int-file:outbound-channel-adapter channel="abc" id="filesout"         directory-expression="@outpathbean.getpath()"         delete-source-files="true" filename-generator="filenamegenerator" >         <int-file:request-handler-advice-chain>          <bean class="org.springframework.integration.handler.advice.expressionevaluatingrequesthandleradvice">             <property name="onsuccessexpression" value="payload.delete()" />           </bean>     </int-file:request-handler-advice-chain>         </int-file:outbound-channel-adapter>    <bean id="ftpclientfactory"     class="org.springframework.integration.ftp.session.defaultftpsessionfactory">     <property name="host" value="${ftp.ip}"/>     <property name="port" value="${ftp.port}"/>     <property name="username" value="${ftp.username}"/>     <property name="password" value="${ftp.password}"/>     <property name="clientmode" value="0"/>     <property name="filetype" value="2"/>     <property name="buffersize" value="100000"/> </bean>         <int:channel id="ftpchannel"/>  <int-ftp:inbound-channel-adapter id="ftpinbound"     channel="ftpchannel"     session-factory="ftpclientfactory"     charset="utf-8"     local-directory="file:${paths.root}"     delete-remote-files="true"     temporary-file-suffix=".writing"     remote-directory="${file.ftpfolder}"      filter="compositefilterremote"      preserve-timestamp="true"      auto-startup="true">     <int:poller fixed-rate="1000"/> </int-ftp:inbound-channel-adapter> <int-ftp:outbound-channel-adapter id="ftpoutbound"     channel="ftpchannel"     session-factory="ftpclientfactory"     charset="utf-8"     remote-file-separator="/"     auto-create-directory="true"     remote-directory="${file.ftpfolder}"      use-temporary-file-name="true"      temporary-file-suffix=".writing">     <int-ftp:request-handler-advice-chain>          <bean class="org.springframework.integration.handler.advice.expressionevaluatingrequesthandleradvice">             <property name="onsuccessexpression" value="payload.delete()" />           </bean>     </int-ftp:request-handler-advice-chain>   </int-ftp:outbound-channel-adapter> 

using suggestion in @gary's answer, have added customfilter ftp inbound channel filter attribute. checks regular expression of file name follows

@override public list<ftpfile> filterfiles(ftpfile[] files) {     list<ftpfile> ret = new arraylist<ftpfile>();     pattern pattern = pattern.compile("~.*?~");     matcher matcher;     (ftpfile file : files)      {         matcher = pattern.matcher(file.getname());         if(matcher.matches())         {             ret.add(file);         }     }     return ret; } 

due ~something~ files picked , sent final destination.

my questions are:

  1. the files being sent final destination ftp location have different pattern don't know put(something@something@something).
  2. sometimes ftp folder may tampered , file deleted. if spring rewrite file. same file gets written again in local-directory mentioned in <ftp:inbound-channel-adapter>. ftp outbound channel adapter not pick file , put in ftp location. according @gary's answer need configure filter inbound channel adapter avoid accept once filter.
  3. does mean should create 2 separate channels , 2 different flows 1 , 1 forth? right way forward requirement?

thanks help

edit::

i have tried implement 2 different processes. 1 pickup files remotedir pattern ~something~ , local directory pattern something@something@something. though basic functionality working, if file in remote dir deleted cannot execute second flow again. gary said accept filter needs in place dont know how use both custom filter , accept filter.

any suggestions appreciated

the acceptoncefilelistfilter configured default. use local-filter on inbound adapter use different filter (such acceptallfilelistfilter). see the documentation.

that said, application looks odd - appears fetching files , sending them back.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -