I'm new to Spring integration sftp.Now,I want to download files from multiple directories.then it seems that SFTP Outbound Gateway is my chocie,but I only find examples using XML config.How can this be done using Java config? My configuration class:
@Configuration
public class SftpConfig {
@Bean
public SessionFactory<LsEntry> sftpSessionFactory(){
DefaultSftpSessionFactory defaultSftpSessionFactory = new DefaultSftpSessionFactory();
...
return new CachingSessionFactory<LsEntry>(defaultSftpSessionFactory);
}
@Bean
@InboundChannelAdapter(channel = "sftpChannel",autoStartup = "false", poller = @Poller(fixedDelay = "5000"))
public MessageSource<File> sftpMessageSource() {
...
}
@Bean(name = "lsGateway")
@ServiceActivator(inputChannel = "sftpChannel")
public MessageHandler handlerLs(){
SftpOutboundGateway sftpOutboundGateway = new SftpOutboundGateway(sftpSessionFactory(),"ls","payload");
sftpOutboundGateway.setLocalDirectory(new File("sftp-gateway"));
return sftpOutboundGateway;
}
}
@MessagingGateway
public interface OutboundGatewayOption {
@Gateway(requestChannel = "sftpChannel")
public List<Boolean> lsGetAndRmFiles(String dir);
}
but when I start the app,nothing happens,where is wrong?
----update--- My test class
@SpringBootTest(classes = Application.class)
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@Configuration
@EnableIntegration
@Slf4j
@MessageEndpoint
public class SftpConfigTest{
@Autowired
private OutboundGatewayOption gatewayOption;
@Test
public void test(){
gatewayOption.lsGetAndRmFiles("/");
}
}