I have a condition where I should read the file from SFTP remote location with the following steps:
Read file from SFTP location say
inputfolder.Process file and call a REST API with the content of file.
If the call is successful move the remote SFTP file to
archivefolder else move the remote SFTP file toerrorfolder.
I am thinking of two approaches. I don't know which are possible.
First, read the file from SFTP remote location to local and delete it from remote. Then call the REST API. According to response of REST call, success or error upload the file to remote folder.
Second, read the file from SFTP remote location to local. Then call the REST API. According to response of REST call, success or error upload the file to remote folder.
Can anyone enlighten me which of the approach is possible and convenient? I would appreciate if you can mention the channel adapters as well.
So far I am able to call 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" />
I want to move the remote file to another location in remote folder once the API call is success after evaluating the API call response. My question is how do I move the remote file to another remote location based on the response of http:outbound-gateway?
AcceptOnceFileListFilteris there for local files by default. - Artem Bilanhttp:outbound-gateway? - nebulahttp:outbound-gatewayresponse how would I get the file fromsingleFilechannel? And based on the file name how to move file in sftp location from one folder to another? - nebula