首先感谢关注
在我的spring集成项目中,我使用int-ftp:outbound-gateway
适配器在ftp服务器上运行命令,我想从服务器检索文件并替换为本地文件,如果存在,则创建新的,并从服务器中删除它,我写了适配器代码来执行操作,但不能正常工作,我的代码是:
<int:channel id="inbound1"/>
<int-ftp:outbound-gateway id="gatewayGet"
session-factory="ftpClientFactory"
request-channel="inbound1"
reply-channel="outbound"
reply-timeout="777"
mode="REPLACE"
auto-create-local-directory="true"
command="mget"
command-options="-R"
expression="payload"
filename-pattern="*"
local-directory-expression="'./backup/' +#remoteDirectory">
</int-ftp:outbound-gateway>
<int-ftp:outbound-gateway id="gatewayRM"
session-factory="ftpClientFactory"
request-channel="outbound"
reply-channel="outboundRemoved"
reply-timeout="777"
command="rm"
expression="headers['file_remoteDirectory'] + '/' + headers['file_remoteFile']"
>
</int-ftp:outbound-gateway>
<int:channel id="outbound">
<int:interceptors>
<int:wire-tap channel="logger"/>
</int:interceptors>
</int:channel>
<int:channel id="outboundRemoved">
<int:interceptors>
<int:wire-tap channel="logger"/>
</int:interceptors>
</int:channel>
在第一步中成功检索文件但不覆盖文件,创建新文件,在第二步中从服务器删除文件时,抛出以下异常:
org.springframework.messaging.MessagingException: Failed to execute on session; nested exception is java.io.IOException: Failed to delete '//'. Server replied with: 550 File not found
我可以在检查有效负载中接收消息并且是否存在文件发送以删除通道?