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.

  1. in onsuccessexpression use payload , add successchannel.

  2. make successchannel <publish-subsribe-channel/>.

  3. first subscriber (order="1") <service-activator/> payload.delete().

  4. 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

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -