0
<int-sftp:outbound-gateway id="sftpOutBound"
    session-factory="sftpSessionFactory"   expression="payload" command="put" request-channel="outboundFtpChannel"
    remote-directory="/tmp/tsiftp" reply-channel="sftpReplyChannel"/>

with the above xml, i can send files and get reply . In java, how to set the remote directory in SftpOutboundGateway .If I use SftpMessageHandler,is there any possibility to get reply.Commented code is transferring files but no reply.

 @Bean
@ServiceActivator(inputChannel = "outboundFtpChannel")
public MessageHandler transfertoPeopleSoft(){
 /*  SftpMessageHandler handler = new SftpMessageHandler(sftpSessionFactory());
     handler.setRemoteDirectoryExpression(new LiteralExpression("/tmp/tsiftp"));
     return handler;*/
    SftpOutboundGateway sftpOutboundGateway = new  SftpOutboundGateway( sftpSessionFactory(), "put", "/tmp/tsiftp");
    sftpOutboundGateway.setOutputChannelName("sftpReplyChannel");
    return sftpOutboundGateway;
}

 Exception I am getting is
   exception is org.springframework.expression.spel.SpelParseException: Expression [/tmp/tsiftp] @0: EL1070E: Problem parsing left operand

Thanks for your help.

cherry
  • 127
  • 9

1 Answers1

0

The remote directory for the SftpOutboundGateway can be configured by the SftpRemoteFileTemplate and its:

/**
 * Set the remote directory expression used to determine the remote directory to which
 * files will be sent.
 * @param remoteDirectoryExpression the remote directory expression.
 */
public void setRemoteDirectoryExpression(Expression remoteDirectoryExpression) {

https://docs.spring.io/spring-integration/docs/5.0.0.RELEASE/reference/html/sftp.html#sftp-rft

Feel free to raise a JIRA for improvements on the matter.

I know that Expression variant isn't so useful because you need to use SpelExpressionParser or just LiteralExpression just for simple dir variant.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • thank you @artem, I will try that. Is there any option to delete the local file after transferring for put command. – cherry Jan 04 '18 at 21:30
  • M-m-m. No, there is no. You can do that as a service activator after `SftpOutboundGateway` performing simple `File.delete()` operation. The original file you can store in the message headers do not lose it in between. – Artem Bilan Jan 04 '18 at 21:37