我有一个集成案例,从FTP获取xml有效负载然后使用http出站通道将有效负载发送到webservice,ftp inbound-channel-adapter有一个名为local-directory的强制属性,远程ftp文件将在这里下载,但是当我重新启动时,似乎将再次处理本地目录中的所有文件,我可以知道如何避免这种情况吗?一种可能的方法是删除ftp inbound-channel-adapter中的本地文件,怎么做,你能建议吗?
谢谢
我的Spring集成配置
<ftp:inbound-channel-adapter
channel="requestChannel"
session-factory="ftpClientSessionFactory"
remote-directory="/outbound"
local-directory="/temp"
auto-create-local-directory="true"
delete-remote-files="false"
filename-pattern="*.xml"
temporary-file-suffix=".writing">
<int:poller fixed-delay="5000" max-messages-per-poll="10"/>
</ftp:inbound-channel-adapter>
<int:chain id="inboundChain" input-channel="requestChannel" output-channel="replyChannel">
<int:transformer ref="xmlToJsonTransformer" />
<int:transformer ref="jsonToMapTransformer" />
<int:header-enricher>
<int:header name="Content-Type" value="application/json" overwrite="true"/>
</int:header-enricher>
<http:outbound-gateway expected-response-type="java.lang.String"
url="http://localhost:8080/postService/postupdate"
http-method="POST"
extract-request-payload="true"
request-factory="requestFactory">
</http:outbound-gateway>
</int:chain>
2 回答
将
ExpressionEvaluatingRequestHandlerAdvice
添加到出站网关以删除该文件 . 有关示例,请参阅Expression Evaluating Advice Demo in the retry-and-more sample - 它会删除或重命名文件,具体取决于成功或失败 .谢谢Gray的建议,这是我更正的配置