Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring integration Spring integration FTP:删除所有源文件夹文件时自动停止文件入站通道适配器_Spring Integration - Fatal编程技术网

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>