java - Chaining together channels removes the file_originalFile header -



java - Chaining together channels removes the file_originalFile header -

i have requirement want utilize ftp , set file in dynamic local-directory. want add together age filter. not allow old files through. works file properly. added custom filter , checked file objects creation date using code:

int agelimit = integer.parseint(props.getproperty("file.age")); basicfileattributes view = null; seek { view = files.getfileattributeview( paths.get(f.getabsolutepath()), basicfileattributeview.class).readattributes(); } grab (ioexception e1) { // todo auto-generated grab block e1.printstacktrace(); } filetime ft = view.creationtime(); if (((new date()).gettime() - (((ft.to(timeunit.milliseconds))/* / 10000l) - 11644473600000l*/))) > agelimit * (24 * 60 * 60 * 1000))// file creation // date(converted // // java.util.date) // - current // date > // oldness in ms { logger.info("file old:" + (f.getname())); homecoming false; }

this works fine int-file adapter. when added ftp support, object got in payload ftpfile object. not give creationdate gives lastly modified date. lastly modified date not usefull me. hence had configure ftp , chain file adapter directory.

the int-ftp:inbound-channel-adapter picks file ftp site , puts in local directory.

this file picked int-file:inbound-channel-adapter , set in final destination.

this 2 step process pickup file set in ftp location.

the filter class works on int-file:inbound-channel-adapter. chaining working.

the problem in deletion of original files. ftp site file(remote-directory) gets deleted automatically. local-directory file picked int-file:inbound-channel-adapter not deleted.

this configuration.

<int:channel id="ftpchannel"/> <int-ftp:outbound-channel-adapter id="ftpoutbound" channel="ftpchannel" session-factory="ftpclientfactory" charset="utf-8" remote-file-separator="/" auto-create-directory="true" remote-directory="." use-temporary-file-name="true" /> <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="." filename-pattern="*${file.char}*${file.char}*${file.char}*${file.char}*${file.char}*" preserve-timestamp="true" auto-startup="true"> <int:poller fixed-rate="1000"/> </int-ftp:inbound-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-file:outbound-channel-adapter channel="abc" id="filesout" directory-expression="@outpathbean.getpath()" delete-source-files="true" filename-generator="filenamegenerator" /> <int:header-enricher input-channel="ftpchannel" output-channel="ftpchannel"> <int:header name="file_originalfile" ref="getpath" method="getcurrentpath" /> </int:header-enricher> <int-file:inbound-channel-adapter id="filesin" directory="file:${paths.root}" channel="abc" filter="compositefilter" > <int:poller id="poller" fixed-delay="5000" /> </int-file:inbound-channel-adapter> <int:channel id="abc"/>

the customfilefilter , filenamegenerator beans defined.

i have added header-enricher add together file_originalfile header read somewhere header dropped if file used twice/ chained in situation. though beans method gets called , have written next code in it, file not deleted file adapters source directory.

public string getcurrentpath(message<file> payload) { file f = payload.getpayload(); if (payload.getheaders().get(fileheaders.original_file)== null) { homecoming f.getabsolutepath(); } else { payload.getheaders().get(fileheaders.original_file).tostring(); } homecoming null; }

what doing wrong?? have tried using header-enricher abc channel not luck!

hope problem clear now.. help

regarding to:

cannot convert value of type [org.springframework.integration.endpoint.eventdrivenconsumer] required type [org.springframework.messaging.messagechannel] property 'outputchannel': no matching editors or conversion strategy found

since have <int-ftp:outbound-channel-adapter id="ftpoutbound" channel="ftpchannel"

you should utilize channel bean name <int:transformer id="testtransformer" input-channel="ftpinbound", rather id of adapter <int:transformerd="testtransformer" input-channel="ftpchannel"

java spring-integration

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -