1
Spring是新增功能,可以在计算如何将sftp出站网关与文件出站网关正确链接在一起时使用一些帮助。我想确认文件已被sftp处理过,然后将其移至归档位置。春季SFTP和文件出站网关链
本质上,我有一个目录,其中的文件被发送到sftp'd别的地方。文件被传输后,该文件应该被移动到存档目录。
每个代码段独立工作,但尝试连接两个时失败。我无法使用我通常会回复的频道,因为回复频道会确认文件已远程保存到哪里,并且.msg会被移至归档目录。
我怀疑订单没有做我认为的事。
目前,该文件将90%的时间移动到归档目录,而不会丢失该文件。
这是可能的,还是我只是吠叫错了树?有没有办法配置sftp:outbound-gateway下游,还是应该尝试使用不同的方法?
<!-- START: SFTP files-->
<int-file:inbound-channel-adapter
directory="file:${sftp.repo}"
channel="SFTPchannel"
prevent-duplicates="false"
ignore-hidden="true" />
<int-sftp:outbound-gateway
session-factory="SFTPFactory"
request-channel="SFTPchannel"
order="1"
command="mput"
command-options="-1"
expression="payload"
mode="REPLACE"
use-temporary-file-name="false"
remote-filename-generator="filenameGenerator"
auto-create-directory="false"
remote-directory="${sftp.remote.destination}"/>
<int-file:outbound-gateway
request-channel="SFTPchannel"
order="2"
directory-expression="'${repository.directory}/'+new java.text.SimpleDateFormat('yyyyMMdd').format(new java.util.Date())"
mode="REPLACE"
auto-create-directory="true"
filename-generator="filenameGenerator"
delete-source-files="true"
reply-channel="nullChannel" />
<!-- END: SFTP files-->
嗨加里,非常有帮助。后续处理: 是否可以在值中使用文件名生成器来生成要归档的文件的文件名? (新的java.io.File('$ {repository.directory}/$ {archive.dir} /'+ new java.text.SimpleDateFormat(''))(
HungryandConfused
不要在注释中放置代码/配置;你可以看到它几乎不可读;改为编辑问题。另外,SO不喜欢对答案进行扩展评论,你通常应该要求跟进作为新问题并参考这个问题。你可以做任何你想做的事情;它是SpEL--参见[Spring Reference](http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/expressions.html)。如果你想做一些比SpEL更复杂的东西,只需在“successChannel”和“failureChannel”下游添加组件。 –