我有一个条件,我应该通过以下步骤读取SFTP远程位置的文件后,远程SFTP位置移动文件:从SFTP位置Spring集成:处理
阅读文件说
input
文件夹。处理文件并使用文件的内容调用REST API。
如果调用成功将遥控SFTP文件
archive
文件夹其他远程SFTP文件移动到文件夹error
。
我想到了两种方法。我不知道哪一个可能。
首先,将文件从SFTP远程位置读取到本地并从远程删除。然后调用REST API。根据REST调用的响应,成功或错误将文件上传到远程文件夹。
其次,将文件从SFTP远程位置读取到本地。然后调用REST API。根据REST调用的响应,成功或错误将文件上传到远程文件夹。
任何人都可以启发我哪种方法可行和方便吗?如果您能提及通道适配器,我将不胜感激。
到目前为止,我可以调用REST API。
<int-sftp:inbound-channel-adapter id="sftpInbondAdapter"
auto-startup="true"
channel="receiveChannel"
session-factory="sftpSessionFactory"
local-directory="${local.dir}"
remote-directory="${sftp.dir.input}"
auto-create-local-directory="true"
delete-remote-files="true"
filename-pattern="*.txt">
<int:poller fixed-rate="60000" max-messages-per-poll="1" />
</int-sftp:inbound-channel-adapter>
<int:channel id="receiveChannel"/>
<int:splitter input-channel="receiveChannel" output-channel="singleFile"/>
<int:channel id="singleFile"/>
<int:service-activator input-channel="singleFile"
ref="sftpFileListenerImpl" method="processMessage" output-channel="costUpdate" />
<int:channel id="costUpdate" />
<int:header-enricher input-channel="costUpdate" output-channel="headerEnriched">
<int:header name="content-type" value="application/json" />
</int:header-enricher>
<int:channel id="headerEnriched" />
<int-http:outbound-gateway
url="${cost.center.add.rest.api}" request-channel="headerEnriched"
http-method="POST" expected-response-type="java.lang.String" reply-channel="costAdded" >
</int-http:outbound-gateway>
<int:publish-subscribe-channel id="costAdded" />
我想移动远程文件到另一个位置在远程文件夹一次API调用是评估API调用响应之后的成功。我的问题是如何根据http:outbound-gateway
的响应将远程文件移动到另一个远程位置?
对不起,你的场景看起来不错。你面临什么问题?删除或不删除远程文件并不会让你感兴趣,因为默认情况下'AcceptOnceFileListFilter'就是用于本地文件的。 – 2014-12-03 12:32:11
实际上,我想在评估API调用响应后,将API调用成功后,将远程文件移动到远程文件夹中的另一个位置。我的问题是,如何根据“http:outbound-gateway”的响应将远程文件移动到另一个远程位置? – nebula 2014-12-03 15:04:14
现在很清楚。你没有在......之前指定具体问题吗?Gary的答案是否适合你? – 2014-12-03 15:06:14