PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, August 1, 2022

[FIXED] How to trigger and poll an ftp outbound gateway

 August 01, 2022     ftp, spring, spring-integration, spring-integration-dsl     No comments   

Issue

I am trying to transfer files from an ftp server using the ftp outbound gateway with recursive method as my ftp server will generate new random name folder and I need to fetch everything. I only know this method work, unless anyone can suggest easier one. Anyway, this is my code.

@Bean(value = "ftpTolocal")
public IntegrationFlow fileToFile() {
    IntegrationFlow flow = IntegrationFlows
            .from("inputChannel")
            .handle(Ftp.outboundGateway(defaultFtpSessionFactory(),
                    AbstractRemoteFileOutboundGateway.Command.MGET,
                    null)
                    //.regexFileNameFilter("(.*n.txt)")
                    .autoCreateDirectory(true)
                    .options(AbstractRemoteFileOutboundGateway.Option.RECURSIVE)
                    .localDirectoryExpression("'/localDirectory/' + #remoteDirectory"))
            .channel("nullChannel")
            
            .get();
    return flow;
}

I have searched and the answer I always get is to create an inputChannel message but I couldn't find one that actually tells me how to do it. I also see many xml solution, but I couldn't find how to implement it. FTP integration guide seems rare and the explanation seems difficult to understand for a rookie like me. Thanks in advance.


Solution

@Bean
IntegrationFlow polled() {
    return IntegrationFlows.fromSupplier(() -> "testMessage",
                    e -> e.poller(Pollers.fixedDelay(Duration.ofSeconds(5))))
            .handle(System.out::println)
            .get();
}


Answered By - Gary Russell
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing