I have a file in remote FTP, say "abc.txt". This file will be updated for every minute. I have configured my FTP Inbound Channel Adapter to retrieve the same file for every minute.
This works fine for the first time (i.e. the local directory is still empty). However, for the 2nd time onward, the intermediate file abc.txt.writing
cannot replace the original abc.txt
file. In other words, both the abc.txt
(old version) and abc.txt.writing
will coexist in the same directory. (with the new version data). (No error prompt)
Am I hitting a bug or I have to set some parameter such that the old version of file will be deleted first such that the abc.txt.writing
could be successfully renamed.
<bean id="ftpSessionFactory"
class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory"
p:host="127.0.0.1"
p:port="21"
p:username="myusername"
p:password="mypassword">
<bean id="cachingSessionFactory" class="org.springframework.integration.file.remote.session.CachingSessionFactory">
<constructor-arg ref="ftpSessionFactory" />
<constructor-arg value="1" />
<property name="sessionWaitTimeout" value="1000" />
</bean>
<int-ftp:inbound-channel-adapter id="myChannel"
channel="nullChannel"
session-factory="cachingSessionFactory"
filename-pattern="abc.txt"
remote-directory="/"
preserve-timestamp="true"
local-directory="c:/temp">
<int:poller cron="15 * * * * ?" max-messages-per-poll="1" />
</int-ftp:inbound-channel-adapter>
c:\temp> dir /a
06/23/2017 11:44 AM 840,000 abc.txt
06/23/2017 11:45 AM 840,000 abc.txt.writing
int-ftp:outbound-channel-adapter
instead ofint-ftp:inbound-channel-adapter
? Becauseint-ftp:outbound-channel-adapter
has an attributemode="REPLACE"
using which you can get what you desired. The condition is that you should use spring integration version 4.1 or above. – Ashok.N