I'm using the DSL API way for configuring an SftpOutboundGateway for issuing custom commands. In the example below I'm uploading a file and move it remotely afterwards:
public IntegrationFlow sftpOutboundFlow() {
return from(getFileToSftpChannel()).handle(Sftp.outboundGateway(getSftpSessionFactory(), PUT, "dir")).handle(Sftp.outboundGateway(getSftpSessionFactory(), MV, "dir")).channel(new NullChannel()).get();
But, when I run this, I get:
Caused by: java.lang.IllegalArgumentException: 'remoteDirectoryExpression' is required
at org.springframework.util.Assert.notNull(Assert.java:115)
at org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:276)
at org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:272)
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.doPut(AbstractRemoteFileOutboundGateway.java:597)
The reason is that RemoteFileTemplate is supposed to be initialized by Spring (InitializingBean, BeanFactoryAware) but it is not:
AbstractRemoteFileOutboundGateway
/**
* Construct an instance with the supplied session factory, a command ('ls', 'get'
* etc), and an expression to determine the filename.
* @param sessionFactory the session factory.
* @param command the command.
* @param expression the filename expression.
*/
public AbstractRemoteFileOutboundGateway(SessionFactory<F> sessionFactory, Command command, String expression) {
this(new RemoteFileTemplate<F>(sessionFactory), command, expression);
}
Is this a bug or am I using this incorrectly? Thanks.