Spring integration FTP: Stop file inbound-channel-adapter automatically when all source folder files are deleted -
is there configuration settings/expression stop channel adapter based on condition (i.e, stop channel adapter when source folder empty)?
i can programatically below approach won't work in case.
config:
<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>
code:
fileinbound = context.getbean("fileinbound", sourcepollingchanneladapter.class); if (fileinbound.isrunning() && issourcefolderempty()) { fileinbound.stop(); }
something should work.
in
onsuccessexpression
usepayload
, addsuccesschannel
.make
successchannel
<publish-subsribe-channel/>
.first subscriber (
order="1"
)<service-activator/>
payload.delete()
.second subscriber (
order="2"
)<chain/>
starts<filter/>
checks if directory empty...
.
<chain ...> <filter expression="new java.io.file('/tmp/foo').list().length == 0" /> <transformer expression="@fileinbound.stop()"/> <control-bus/> </chain>
Comments
Post a Comment