Spring integration Spring integration FTP:删除所有源文件夹文件时自动停止文件入站通道适配器
是否有任何配置设置/表达式可根据条件停止通道适配器(即,当源文件夹为空时停止通道适配器) 我可以按照下面的程序来做,但这种方法在我的情况下不起作用 配置:Spring integration Spring integration FTP:删除所有源文件夹文件时自动停止文件入站通道适配器,spring-integration,Spring Integration,是否有任何配置设置/表达式可根据条件停止通道适配器(即,当源文件夹为空时停止通道适配器) 我可以按照下面的程序来做,但这种方法在我的情况下不起作用 配置: <file:inbound-channel-adapter prevent-duplicates="false" auto-startup="false" auto-create-directory="true" directory="${local.tmp.path}" id="fileInbound" channel="outpu
<file:inbound-channel-adapter prevent-duplicates="false" auto-startup="false" auto-create-directory="true" directory="${local.tmp.path}" id="fileInbound" channel="outputChannel" filename-pattern="*.xml">
<int:poller fixed-rate="${local.transfer.interval}" max-messages-per-poll="100" />
</file:inbound-channel-adapter>
<sftp:outbound-channel-adapter id="sftpFileOutboundAdapter" auto-create-directory="true" session-factory="sftpSessionFactory" channel="outputChannel" charset="UTF-8" remote-directory="${ftp.path}">
<sftp:request-handler-advice-chain>
<bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
<property name="onSuccessExpression" value="payload.delete()" />
<property name="trapException" value="true" />
</bean>
</sftp:request-handler-advice-chain>
</sftp:outbound-channel-adapter>
这样的办法应该行得通
onSuccessExpression
中,使用payload
并添加一个successChannel
成功频道设置为
order=“1”
)是一个具有有效负载的
。delete()
order=“2”
)是一个以检查目录是否为空的
开头的
你好,加里,谢谢你的建议。过滤器中是否有任何SpEL表达式可用于检查目录是否为空()?新建java.io.File('/tmp/foo').list()。长度==0“?谢谢。它工作得很好。作为此任务的继续,我还想启动通道适配器。类似于…
的内容,但其计算结果始终为“false”。是否有任何建议?类似于“@fileInbound.isRunning()”的内容确定“:@fileInbound.start()==null?”启动“:“从不”
?
fileInbound = context.getBean("fileInbound", SourcePollingChannelAdapter.class);
if (fileInbound.isRunning() && isSourcefolderEmpty()) {
fileInbound.stop();
}
<chain ...>
<filter expression="new java.io.File('/tmp/foo').list().length == 0" />
<transformer expression="@fileInbound.stop()"/>
<control-bus/>
</chain>