简体   繁体   中英

Retry Spring Integration FTP Inbound Channel Adapter

Currently I have a basic FTP Inbound Channel Adapter, configured with a poller

<int-ftp:inbound-channel-adapter id="ftpInboundChannelAdapter">
        <int:poller cron="#{fooProperties['foo.ftp.cron']}" max-messages-per-poll="-1" />
</int-ftp:inbound-channel-adapter>

The cron is once a day at a specific time.

However, on occasion, the FTP server we are connecting to will throw an error, eg

org.apache.commons.net.ftp.FTPConnectionClosedException: FTP response 421 received.  Server closed connection.

In this case, we would like to "repoll", a configurable amount of times.

I read about int:request-handler-advice-chain but it doesnt look like you can use this on the FTP adapter's poller.

I am using SI 2.2.6, but could upgrade if needed

You can use a custom Trigger bean instead of a cron trigger.

Add an error-channel to the poller to capture the exception and, on the error channel flow, set some state in the trigger bean that an error occurred.

If no error occurred, return the time you want to run tomorrow when nextExecutionTime() is called.

If an error occurred, return the time when you want to retry (and reset the error state).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM