Spring Integration FTP Outbound: How to multiple FTP host sequentially in case of failure


April 2019


30 time


I have a primary ftp host A and secondary ftp host B. If the ftp outbound A fails then I need to perform ftp outbound to B. Currently my IntegraitonFlow DSL performs the following logic * Perform FTP to primary host A -> On SUCCESS expression advice delete local temp files -> On FAILURE expression advice display error message

How do i tweak the failure advice to perform FTP to host B

My DSL looks like this

public IntegrationFlow jmsInboundFlow(DefaultMessageListenerContainer myJmsListenerContainerFactory,
        SessionFactory<FTPFile> sessionFactory) {
    return IntegrationFlows.from(Jms.messageDrivenChannelAdapter(myJmsListenerContainerFactory))
            .channel(c -> c.executor(Executors.newCachedThreadPool()))
                    c -> c.advice(expressionAdvice(c))

public Advice expressionAdvice(GenericEndpointSpec<FileTransferringMessageHandler<FTPFile>> c) {
    ExpressionEvaluatingRequestHandlerAdvice advice = new ExpressionEvaluatingRequestHandlerAdvice();
    advice.setOnFailureExpressionString("payload + ' failed to upload'");
    return advice;

0 answers