I have created a Sftp outbound flow in spring DSL also I have created one more File inbound flow on top of the Sftp outbound flow for look up files from my local directory and send it to the Message channel which is responsible for copying the file to the remote directory but when I am running my code no file is getting copied in remote directory. So I am getting stuck in this point, Can any one please provide any pointer to it as I am not able to proceed.
This is my session Factory...
@Autowired
private DefaultSftpSessionFactory sftpSessionFactory;
@Bean
public DefaultSftpSessionFactory sftpSessionFactory() {
DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory(
true);
factory.setHost("111.11.12.143");
factory.setPort(22);
factory.setUser("sftp");
factory.setPassword("*******");
return factory;
}
This is my sftp outbound flow..
@Bean
public IntegrationFlow sftpOutboundFlow() {
return IntegrationFlows
.from("toSftpChannel")
.handle(Sftp.outboundAdapter(this.sftpSessionFactory)
.remoteFileSeparator("\\")
.useTemporaryFileName(false)
.remoteDirectory(remDir)).get();
}
This is my File inbound flow..
@Bean
public IntegrationFlow fileReadingFlow() {
return IntegrationFlows
.from(fileMessageSource(),
new Consumer<SourcePollingChannelAdapterSpec>() {
@Override
public void accept(SourcePollingChannelAdapterSpec e) {
e.poller(Pollers.fixedRate(6));
}
})
.transform(Transformers.fileToByteArray())
.channel(MessageChannels.queue("fileReadingResultChannel"))
.get();
}
This the MessageSource method.......
@Bean
public MessageSource<File> fileMessageSource() {
FileReadingMessageSource source = new FileReadingMessageSource();
source.setDirectory(new File(localDir));
source.setAutoCreateDirectory(true);
System.out.println("enter fileMessageSource....."+ source.receive());
return source;
}
This is my Junit Test method...
@Autowired
private DefaultSftpSessionFactory sftpSessionFactory;
@Autowired
@Qualifier("toSftpChannel")
private MessageChannel toSftpChannel;
@Autowired
@Qualifier("fileReadingResultChannel")
private PollableChannel fileReadingResultChannel;
@Test
public void testSftpOutboundFlow() {
Message<?> message = ((PollableChannel) fileReadingResultChannel)
.receive(600);
System.out.println("message....."+message);
this.toSftpChannel.send(message);
}