I'm trying to use the outbound gateway to download files from sftp server, my config:
@IntegrationComponentScan
@EnableIntegration
@Configuration
public class FtpConfig {
@Bean(name = "myGateway")
@ServiceActivator(inputChannel = "sftpChannel")
public MessageHandler handlerLs() {
SftpOutboundGateway sftpOutboundGateway = new SftpOutboundGateway(sftpSessionFactory(), "mget", "payload");
sftpOutboundGateway.setLocalDirectory(new File("/Users/xxx/Documents/"));
return sftpOutboundGateway;
}
@MessagingGateway
public interface OutboundGatewayOption {
@Gateway(requestChannel = "sftpChannel")
List<File> mget(String dir);
}
@Bean
public MessageChannel sftpChannel() {
return new DirectChannel();
}
}
and the execute bean:
@Service
public class DownloadService implements InitializingBean{
@Autowired
FtpConfig.OutboundGatewayOption gatewayOption;
@Override
public void afterPropertiesSet() throws Exception {
List<File> files = gatewayOption.mget("/sftp/server/path");
}
}
and I got this exception:org.springframework.messaging.MessageDeliveryException: Dispatcher has no subscribers for channel 'application.sftpChannel'.; Qestion :how can I add the 'subscribers' ?